jquery - Replace several different text words each with a different image -
I do not have the access to convert these sites to HTML and I am not very knowledgeable with jQuery This is very possible.
I have a table that contains many different user names
& lt; Table id = "chat" & gt; & Lt; Td> Tim Burton & lt; / Td> & Lt; Td> Doretha Rose & lt; / Td> & Lt; Td> Selma Jeerik & lt; / Td> & Lt; / Table & gt;
I would just like to search for each user's name within this table and change each name to the avatar of my selection.
I looked at this script, but how has it been modified for my needs
("*"). Each (function () {if ($ (this) children () Length == 0) {var newHTML = $ (this) .html (). ('Basketball', '& lt; img src = "image.jpg" /> '); $ (This) .html (newHTML);}});
The following can do something like:
If you want to use the same avatar and there are only names in the table, then you may want to use simple code:
$ ( '# Chat' TD '). Html ('& lt; img src = "url-k-avatar-of-your-choosing.jpg" />;);
But if you have names and avatars in an array / object, you can loop through the names and use the code at the top:
< Pre> $ .each (name, function (i, name) {$ ('# chat'). ('TD'). Filter (function () {return $ (this) .text () == Name ;}) .HTML ('& lt; img src = "- URL-of-avatar-of-your-choosing.jpg" />;);});
Comments
Post a Comment