开发者

jQuery - hide div which an attribute is under a value or between two values

I try to hide the div which attribute are under a value or between two values (would be better)

--> my JS file

$('#button').toggle(function() {
$('#wrapper').find('div.object').filter(function() {
 return $(this).attr("value") < 800000;}).css('height','0px');
return fals开发者_JAVA百科e; 
}, function() {
$('#wrapper').find('div.object').filter(function() {
 return $(this).attr("value") < 800000;}).css('height','90%');
return false;

});

-->my html

<input type="submit" id="button" value="under 800k">
<div id="wrapper">
<div class="object" value="805000">London</div>
<div class="object" value="710000">Paris</div>
<div class="object" value="860400">Milan</div>
</div>

Thanks for you help!


This toggles the visibility of divs with values between 700k and 800k.

$('#button').click(function() {
    $('#wrapper div.object').filter(function() {
        var v = $(this).attr("value");
        return v > 700000 && v < 800000;
    }).toggle();
});

Demo: http://jsfiddle.net/m3LxR/3/

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜