How can I replace a specific text with HTML objects?
example:
var text = "some text to replace here.... text text text";
var element = $('
').event().something...
function ReplaceWithObject(textSource, textToReplace, objectToReplace);
So I want to get this:
"some text to replace < img src...etc >.... text text text"
And I would like manipulate the object element without call again $() method.
UPDATE: I solved.
thanx @kasdega, i made a new script based in your script, because in your script i can't modify the "element" after replace. This is the script:
$(document).ready(function() {
var text = "some text to replace here.... text text text";
var element = $('
');
text = text.split('here');
$('.result').append(text[0],element,text[1]);
$(element).attr('src','
http://bit.ly/mtUXZZ');
$(element).width(100);
});
I didnt know that append method accept multiples elements. That is the idea, only need to automate for multiple replacements
thanx to all, and here the jsfiddle
JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)