How can I dynamically add rel=”external” to the third level in a nested list?
I’ve tried:
$(document).live("mobileinit", function(){
$("ul#globalMenu").listview();
});
$(document).live( 'pagebeforecreate',function(event){
$('ul#globalMenu li ul li.menuList ul li a').attr('rel', 'external');
});
You could use this selector
#globalMenu > li > ul > li > ul > li > ul > li > aCreated a demo at jsFiddle for you.
$('#globalMenu > li > ul > li > ul > li > ul > li > a').attr("rel", "external");It would also be possible to filter the selection by the number of parent
ulelements but you should stick with the first suggestion.