开发者

Set an event for a div with multiple class

开发者 https://www.devze.com 2022-12-27 00:01 出处:网络
I am tryi开发者_运维百科ng to set an event on a div whos parent has a class=\"classA classB\"; My css is being applied but i cant figure out how to specify it with jquery. How do i set an event with j

I am tryi开发者_运维百科ng to set an event on a div whos parent has a class="classA classB"; My css is being applied but i cant figure out how to specify it with jquery. How do i set an event with jquery for this class combination

$('[class=classA classB]').live('click', function () {
        alert('a');
    });

html

<div class="classA classB">...moredivs...</div>


Chain the classes in the selector, like this:

$('.classA.classB').live('click', function () {
    alert('a');
});

Without a space in-between, the selector will only match element that have all the classes.
Note: the class order doesn't have to match!

0

精彩评论

暂无评论...
验证码 换一张
取 消