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

user1551056
  • 27
  • 1
  • 6

1 Answers1

-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.

Viral Shah
  • 2,263
  • 5
  • 21
  • 36