简体   繁体   中英

Re Positioning html text

I would like to re positioning the <em> tag in label field using jQuery

From: <label><em>*</em> Name</label>
  To: <label>Name <em>*</em></label>

Also check the label contain <em> tag or not?

Thanks in advance.

JSFiddle> http://jsfiddle.net/74gP2/

$('label em').remove();
$('label').append('<em>*</em>');

Try,

var contents = $('label').contents();
var len = contents.length;
$('label').prepend(contents[len-1]);

DEMO

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM