In the below code how to remove the hyperlink after getting the innerHTML:
function test(obj)
{
var a=obj.innerHTML
//remove obj element here
}
$p = $('<a id="name" onclick="var ele=test(this);">').html( "test" );
$('#questions').append( $p );
You can remove an element using the DOM method
removeChild. If you start with a reference to the child [as you seem to in yourtestfunction (theobjargument)], you can remove it like this:(Your question is also tagged jQuery but I see someone pointed you to jQuery’s
removefunction and you said you didn’t want to use that. In any case, for completeness I’ve noted it here.)