我很努力地找到正确的语法来添加一个通过javascript/jquery添加一个具有附加功能的按钮。通过javascript/jquery添加一个带有onclick函数的按钮
现在我想:
list.append("<button onclick='getFeed('http://open.live.bbc.co.uk/weather/feeds/en/PA2/3dayforecast.rss, showFeedResults')'>ButtonTest</button>");
但它返回:
<button onclick="getFeed(" http:="" open.live.bbc.co.uk="" weather="" feeds="" en="" pa2="" 3dayforecast.rss,="" showfeedresults')'="">ButtonTest</button>
从本质上讲,我希望能够创造
<button onclick="getFeed('http://open.live.bbc.co.uk/weather/feeds/en/B1/3dayforecast.rss', showFeedResults)" class="ui-btn-hidden">
在JavaScript中,但可以”不知道如何......'
而且我似乎在创建使用单个和双个qoutation标记的html元素时都遇到了麻烦。
任何意见将不胜感激。
下面的答案是更好的解决方案,但你的问题可以通过使用转义引号像这样的VAR文本=“AAA \” BB“来解决; – 2013-04-23 19:30:22