[jQuery] Replacing DOM Elements While Maintaining Child Elements
Ok, I have this code (I know it's horrific). td class=ms-sbscopes ms-sbcell select class=ms-sbscopes title=Search Scope id=ctl00_PlaceHolderSearchArea_ctl01_SBScopesDDL name=ctl00$PlaceHolderSearchArea$ctl01$SBScopesDDL option value=This SiteThis Site: Hirsch Branding/option /select /td I want to alter this so the td class=... becomes a div (I don't need to maintain the classes) and the /td with a /div while maintaing the select control. I figured it's done with replaceWith but I can't maintain the select.
[jQuery] Refactoring Functions
I wanted a script that would make a sticky footer, and it worked perfectly with this (where 341 is the elements to offset). var height = $(document).height(); var height = height - 341; $('#footer').css('margin-top', height); Then I want this code to re-run on browser resize. I also want to refactor the code above to use a second time. The problem is that (1) it doesn't re-run on browser resize and (2) I don't want to duplicate code. How can I refactor? var height = $(document).height(); var height = height - 341; $('#footer').css('margin-top', height); $(window).resize(function(){ var height = $(document).height(); var height = height - 341; $('#footer').css('margin-top', height); });
[jQuery] Re: Refactoring Functions
Better yet, change line second line of stickFooter function to: var height = $(document).height() - 341; And remove the third line entirely. Carl Thanks for responding Carl. This is what I ended up using as you prescribed. script type=text/javascript var stickyFooter = function() { var height = $(document).height() - 341; $('#footer').css('margin-top', height); } $(document).ready( stickyFooter() ); $(window).resize( stickyFooter() ); /script But Firebug tells me document.body has no properties with the error seemingly in the jQuery library. Thanks!
[jQuery] Re: jQuery Not Adding Class/Attributes in IE
I'm with Karl. I remember IE dying on me when I tried to set an expando called 'all', go figure... So.. use another attribute, jQuery.data or try setAttribute. Not sure whether it will fail as well or not. Sorry for the spamming of the list. I actually figured out why it didn't work. The script I was using (scrollovers - www.scrollovers.com) needed what I was trying to add, but the script was loaded before the document.ready. So the external file (I'm guessing) parsed the DOM, couldn't find what it needed, and just let it go. Once I moved the external script after the jQuery initialization it worked. Thanks.
[jQuery] Re: jQuery Not Adding Class/Attributes in IE
Anyone? On May 26, 8:32 pm, Chris P [EMAIL PROTECTED] wrote: Hello all, For some reason this is not working in IE but fine in Safari/FF. jQuery('ul.nav a').addClass('scrollover').attr('type','scrollover'); You can see it on my site (www.siolon.com). It's suppose to add it in the navigation bar. Cheers.
[jQuery] Re: jQuery Not Adding Class/Attributes in IE
Anyone on this? On May 26, 8:32 pm, Chris P [EMAIL PROTECTED] wrote: Hello all, For some reason this is not working in IE but fine in Safari/FF. jQuery('ul.nav a').addClass('scrollover').attr('type','scrollover'); You can see it on my site (www.siolon.com). It's suppose to add it in the navigation bar. Cheers.