JQuery&子选择器A>B: 不工作?[Chrome 24,JQmobile]
JQuery & Child selector A > B: not working ? [Chrome 24, JQmobile]
给定嵌套的html:
<a class="star">Hello world!
<a class="ui-icon-star"> hello </a>
</a>
我使用了以下JS:
$('.star').click(function () {
$(this).toggleClass("favorited");
$(this > '.ui-icon-star').toggleClass("ui-icon-starred");
});
更改.star和child.ui图标的star元素,但它不适用于child。我的[选择器(?)]错误在哪里?大约$(这个>.ui图标星)。
1:http://jsfiddle.net/tNwND/1/2:http://www.w3.org/TR/CSS21/selector.html
这是因为您的标记无效,浏览器以这种方式呈现您的标记:
<a class="star">Hello world! </a>
<a class="ui-icon-star"> hello </a>
因此,单击的元素没有.ui-icon-star
子元素。
相关文章:
- Chrome WebKitGetUserMedia
- JQueryhide()不适用于Mozzilla,但适用于Chrome
- 在chrome.tabs.onCreated之后加载HTML页面
- chrome扩展中的navigator.geolocation.getCurrentPosition
- chrome扩展:尽管运行了at:documentidle,js脚本还是过早启动
- document.open/document.write没有正确地清除chrome中的文档——这是chrome的错误吗
- chrome扩展更改主机/域警告
- Chrome开发工具(如何知道我在调用哪个javascript对象)
- 如何在chrome扩展中重定向到html页面
- Chrome扩展没有't在重新加载之前考虑期权价值
- Google/html5语音识别JavaScript SDK Chrome网络工具包SpeechRecognition
- 激活chrome上的chrome.notifications对象
- 如何通过自己获得Chrome扩展的用户反馈/错误报告
- JS可以在Chrome中工作,但不能在Firefox中工作
- Chrome加载旧版本的Javascript文件
- 试图阻止Chrome通过扩展关闭
- 如何在chrome扩展中存储数据/结果,以及如何使用setTimeout使其只被调用一次
- JS表单提交"无法使用Chrome数据保护程序加载此页面.尝试重新加载页面.调试信息:POST CISmtuK
- 是什么让一个“;Uncaught RangeError:超过了最大调用堆栈大小“;错误(Chrome,在其他浏览器中显示
- JQuery&子选择器A>B: 不工作?[Chrome 24,JQmobile]