简体   繁体   中英

append div tag Into anchor tag using jquery?

Greeting..

In Browser Html is

<div tabIndex="0" title="People Picker" class="ms-inputuserfield">Administrator</div> 

i want to replacewith look like

<a href='#'> <div tabIndex="0" title="People Picker" class="ms-inputuserfield">Administrator</div></a>

i tried to so much for make this. not succeed yet. plz Help me.

i try by this code :

 var list = $("<a href='#' />");
 $(list).wrapInner($('#maindiv').html())
 $('div.ms-inputuserfield').replaceWith(list);

i knew that i am going wrong way.its replace by anchor.

you could do

$('div.ms-inputuserfield').wrap('<a href="#"/>');

EDIT - fiddle here http://jsfiddle.net/QUcux/

If it's not working, remeber that you must put it in document.ready()

$(document).ready(function(){
    $('div.ms-inputuserfield').wrap('<a href="#"/>');
});

Use the jQuery wrap method.

$('div.ms-inputuserfield').wrap('<a href="#" />');

http://api.jquery.com/wrap/

Thanks

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