2

My requirement is, on a web form if i select some strings, On click of a button i should be able to know if my selected string is in valid HTML syntax or not

 function chkhtml() {
            var code = $("<table><td>");
        code.each(function () {
           if($(this).html())
           {
            alert('success')
           } 
           else
           {
            alert('fail');
           }
        })
    }

Suppose i write the above code, it should alert me false but it alerts true

2

1 Answer 1

-1
var code = $("<div id='foo'>1</div><div id='bar'>2</div>");
code.each(function() {
    alert( $(this).html() ); //returns 1 if HTML 
})

I think this is the probable solution by using HTML and J-Query.

Sign up to request clarification or add additional context in comments.

1 Comment

This does not answer the question, it juste gets the html of the element

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.