chiro chiro - 1 year ago 69
Javascript Question

Echoing Jquery "contains" statement doesn't work

I have php file where I echo JQuery code where I check if checkboxes are checked and than do stuff if they are. But if I use

contains()
code does nothing.

This code works:

"<script type='text/javascript'>
$(document).ready(function(){

$('#filterbutton').click(function() {
if($('#znackaasus').is(':checked'))
{
console.log('checked');
}
});
});
</script>"


But this code breaks whole Jquery and does nothing:

"<script type='text/javascript'>
$(document).ready(function(){

$('#filterbutton').click(function() {
if($('#znackaasus').is(':checked'))
{
$('.tovar:contains('ASUS')').hide();
}
});
});
</script>"

L L L L
Answer Source

Try This:

"<script type='text/javascript'> 
$(document).ready(function(){

$('#filterbutton').click(function() {
if($('#znackaasus').is(':checked'))
    {
     $(\".tovar:contains('ASUS')\").hide();
    }
});
}); 
</script>"

Unsure if this will work as expected, but it might.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download