javascript - How to take html element without text? -


edit:

sorry bad explanation have:

 var x = $("span", this).get( 0 );  var y = x.outerhtml  

and give me: <span>'some text'</span> want tag <span></span> atributes. question how it?;p

thanks help!

the problem in code: var x = $("span", this).get( 0 ); <-- have parent (even tag name) , taking first child var y = x.outerhtml <-- here you're trying parent (you eant - tag name) :%

so, if know var x = $("span"... <---- string - can create string want

var tag = "span"; var x = $(tag, this).get( 0 ); var y = x.outerhtml; // dumbest way var result = '<'+tag+'>'+'<'+tag+'/>'; 

Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -