html - Change an element's text without affecting sibling tags (jQuery) -
I am trying to modify the HTML of this bit with jQuery to remove duplicate arrows:
& lt; Div class = "breadcrumb" & gt; & Lt; A href = "/ spa /" & gt; Home & lt; / A & gt; »» & Lt; A href = "/ spa / image / tid" & gt; Image galleries & lt; / A & gt; & Lt; / Div & gt;
I do not have much luck, however, to change the location and also to strip the HTML tag to the string to use the () function, such as:
& lt; Div class = "breadcrumb" & gt; Home »Image galleries & lt; / Div & gt;
My existing code is:
$ ('breadcrumb'). Each (function () {var mytext = $ (this); var Mytext2 = mytext.text (); mytext.text (mytext2.replace ('»»', '»'))}}; It seems that you are modifying the code using innerText
or using jQuery's .text ()
. Time, HTML is stripped and only text is returned .WinnerHTML
or .html ()
use instead.
Using your "dodgy" code:
$ ('.breadcrumb'). Each (function () {var mytext = $ (this); var mytext2 = mytext.html (); Mytext.html (mytext2.replace ('»»', '»'))}}
< / Div>
Comments
Post a Comment