[jQuery] "not" Filter
[jQuery] "not" Filter
hi,
I wrote a simple code to test the "is" and "not" filters, like this:
Script:
$("#isDiv> div").click(function (){
if ($(this).is(":contains('Offenburg')")) {
alert("Offenburg");
}
if ($(this).not(":contains('Offenburg')")) {
alert("Not Offenburg");
}
});
Html:
<div id="isDiv">
<div class="yellow" style="width:75px; height:75px; marginLeft:
0in; float:left; background:yellow"></div>
<div style="width:75px; height:75px; marginLeft:0in; float:left;
background:blue"></div>
<div class="red" style="width:75px; height:75px; marginLeft:15px;
float:left; background:red"></div>
<div style="width:75px; height:75px; marginLeft:0in; float:left;
background:orange"><br/><span>Offenburg</span></div>
<div class="brown" style="width:75px; height:75px; marginLeft:0in;
float:left; background:brown"></div>
</div>
"is" works as expected, when I click on the div that contains the word
"div" it shows the alert, and for the other divs no.
in the same logic, I suppose for "not", that it will do exactly the
opposite, ie, the alert will arise for all divs that do not contain
"offenburg", but when I tries it, the alert appears for all!!!
Any help please?