Tuesday, July 31, 2012

html – Extract part of inner text from a div using jquery



How do i extract the text part of a div leaving out text of inner html tags


Here is the div



<div class=\"MessageBox\">I want to see only this message<span....>Click Here to collapse</span></div>


Here is the jquery inside a javascript function



var message= $(\".MessageBox\").text();


Right now i am getting

message= \”I want to see only this message Click Here to collapse\”


I want message =\”I want to see only this message\”






Rating: 4 out of 5 based on 4 ratings



The post html – Extract part of inner text from a div using jquery appeared first on Javascript ASK.






via Javascript ASK http://javascriptask.phpfogapp.com/html-extract-part-of-inner-text-from-a-div-using-jquery.html

No comments:

Post a Comment