jQueryUI对话框文本是否有换行选项? |
您所在的位置:网站首页 › js文本框换行 › jQueryUI对话框文本是否有换行选项? |
我正在使用来自Pokemon的数据创建一个网站并尝试执行一个对话框.我尝试在文本中使用JS换行符: function alertBox(monster) { $("#dialog").dialog(); $("#dialog").dialog("option", "title", monster); $("#dialog").text("Height: " + pokemon.height[monster] + "\n" + "Weight: " + pokemon.weight[monster]); }...而且我也尝试过使用html换行标记: function alertBox(monster) { $("#dialog").dialog(); $("#dialog").dialog("option", "title", monster); $("#dialog").text("Height: " + pokemon.height[monster] + "" + "Weight: " + pokemon.weight[monster]); }但似乎都没有返回我正在寻找的换行效果!JS换行符只是一个空格,而html换行标记只是连接到字符串.有没有办法在对话框文本中强制换行? 1> Maximillian ..: jQuery .text()函数自动转义HTML实体,因此您的标记不再被解释为HTML,而是转换为转义文本. 要防止此HTML转义,您需要使用.html()而不是.text()设置内容: function alertBox(monster) { $("#dialog").dialog(); $("#dialog").dialog("option", "title", monster); $("#dialog").html("Height: " + pokemon.height[monster] + "" + "Weight: " + pokemon.weight[monster]); } |
今日新闻 |
推荐新闻 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |