ajax - The function 'has' is not working on loaded data using jQuery -
i using function has() checking if li tag has ul inside. if ul tag in li add css properties, code works when li tags created while rendering page when use ajax , $.each() creating these li items has() not work.
the jquery code is:
$('.inneritems li ul li').has('ul').css({'background-image':'url(images/arrow.png)', 'background-position':'2px center', 'background-repeat':'no-repeat'});
use .find instead, .has test whether has ul.
$('.inneritems li ul li').find('ul').css({'background-image':'url(images/arrow.png)', 'background-position':'2px center', 'background-repeat':'no-repeat'}); edit: seems want instead:
$('.inneritems li ul li:has(ul)').css({'background-image':'url(images/arrow.png)', 'background-position':'2px center', 'background-repeat':'no-repeat'});
Comments
Post a Comment