toolman Posted December 9, 2013 Share Posted December 9, 2013 Hi,I have some background images on the page, however, I want to replace them with a new background image using jQuery.I have this, but it doesn't work: $('td.my class').css('background-image','url(http://www.mywebsite.com/new-image.png)'); Any ideas what I have wrong?Thanks Quote Link to comment https://forums.phpfreaks.com/topic/284653-replace-backgrounf-images-on-page-with-a-new-image/ Share on other sites More sharing options...
cyberRobot Posted December 10, 2013 Share Posted December 10, 2013 It looks like you have a space in your class name. The space actually causes the <td> tag to have two classes "my" and "class". Try removing the space. Quote Link to comment https://forums.phpfreaks.com/topic/284653-replace-backgrounf-images-on-page-with-a-new-image/#findComment-1461950 Share on other sites More sharing options...
Irate Posted December 10, 2013 Share Posted December 10, 2013 Actually, the selector "td.my class" looks for an XML tag named <class> which is a child of a <td> element with a class of 'my'. Class attributes in HTML can be space-separated lists of class names, so as to assign multiple class names to an element. Do you literally have <td class="my class"> in your HTML? If so, try querying $('td.my.class'). Quote Link to comment https://forums.phpfreaks.com/topic/284653-replace-backgrounf-images-on-page-with-a-new-image/#findComment-1461957 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.