good master, have the following html structure
function picnewsTime() {
var obj = $(".time");//JQclasstime
for(var i = 0; i < obj.length ; iPP) {
var txt = obj[i].textContent || obj[i].innerText;//
//JQvar txt = $(this).text();
var newhtml = replacePos(txt, 8, "<strong>");//replacePos()strong
newhtml += "</strong>";//
alert(newhtml);
}
}
picnewsTime();
I failed when I tried to re-write the new newhtml value into span. I could only change all the dates to one value and searched for a few hours. I seemed to use a closure to get the correct result. Js rookie, I really couldn"t handle it. Please help me to see how to write it. Thank you!
maybe my ideas are all wrong, but there is a better way not to follow mine. It is best to omit the class= "time". The premise is that only js and jq can be modified at the front end, and the date passed in the background cannot be moved.
-add:-
I have made it possible for onclick to get the correct results, but how to change the following js to page load and execute it without the step of onclick
function picnewsTime() {
var obj = $(".time");//JQclasstime
for(var i = 0; i < obj.length; iPP) {
(function(arg){
obj[arg].onclick = function() {
var txt = obj[arg].textContent || obj[arg].innerText;//spantxtinnerTextietextContentffch
//JQvar txt = $(this).text();
var newhtml = replacePos(txt, 8, "<strong>");
newhtml += "</strong>";
alert(newhtml);
$(this).html(newhtml);
}
})(i);//
}
}
picnewsTime();