by LGforum February 12th 2012, 3:15 pm
This is both better javascript and easier to understand than the above code:
- Code:
$(function(){
var x=document.getElementById('text_edit').getElementsByTagName('button');
x[0].firstChild.src="NEW IMAGE SRC";
x[1].firstChild.src="NEW IMAGE SRC";
x[2].firstChild.src="NEW IMAGE SRC";
});
See these bits 'x[0].firstChild.src="NEW IMAGE SRC";'
These are the bits changing the images. 0 is the first button. So the bold button. 1 is the second button so the italic button, and so on... just keep duplicating that line and changing the number. Easy right?
And as an FYI to people, using the jQuery attr() function to get a src or href is pointless. As displayed in my above script, it can be access just like that.
'this.src' or 'this.href'
Last edited by LGforum on February 12th 2012, 9:28 pm; edited 1 time in total