0

I want to get value of html Code comments with javascript. For example:

<code data-type="tb-datalazyload" id="frslistCodeArea">
    <!-- <li class="j_thread_list clearfix"></li>--> 
</code>

I want to get the <li class="j_thread_list clearfix"></li>.


I execute it in chrome. why? who can help me?

enter image description here

7
  • Just as <!-- xxx --> in html Commented Apr 23, 2014 at 3:55
  • possible duplicate of Is it possible to get reference to comment element/block by JavaScript? Commented Apr 23, 2014 at 3:56
  • 1
    Heard,yes this is called a "comment" - will be easier to look it up when referred to as such Commented Apr 23, 2014 at 3:56
  • @Djizeus But when i execute" document.getElementsByTagName("code")[0].childNodes[0].nodeValue ", I can get nothing but "". why? Commented Apr 23, 2014 at 4:02
  • 2
    The code works: jsfiddle.net/DerekL/tcWdy Commented Apr 23, 2014 at 4:14

1 Answer 1

0

Here's an answer to that question:

RegEx for match/replacing JavaScript comments (both multiline and inline)

Just use this RegEx instead:

(<![\-\-\s\w\>]*\-\-\>)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.