Reference 1:
Get text in div not inside other tags with jquery
<div id="price">
<small>$</small>
256
</div>
I want to change the number, how to get 256
Code:
$("div#price").prop("lastChild").nodeValue
Reference 2:
How to exclude span tags from j query element content
<td>6666<span class="copy">[复制]</span></td>
I want to achieve click to copy pop-up 6666 content
Code:
<script type="text/javascript" src="jquery-1.8.0.min.js"></script> <script> $ (function () { $ (".copy").bind ("click", function () { var test = $($ (this).prop ('previousSibling')).text(); console.log (test); }) }) </script>
Requirements in the project:
<tr id="tr">
<td class="t-left">
<span class="prev_span">
<span class="vsStyle_node vsStyle_blank"></span>
</span>
<span arrow="true" class="vsStyle_active_node vsStyle_shut"></span>
Fuzhou
</td>
<td>Other Content1</td>
<td>Other Content</td>
</tr>
Requirements: Need to replace Fuzhou with other characters. Do not change the style in the td.
//Assignment operation $("#tr") has the same effect
$("tr[id='tr']).find("td:first").prop("lastChild").nodeValue="赣州市";
Note: Using jQuery1.4.4 in the project will not find the prop method, and the problem will be solved after using 1.9.