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.
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.
Share Improve this question edited Feb 17, 2012 at 9:55 Jignesh Rajput asked Feb 17, 2012 at 9:46 Jignesh RajputJignesh Rajput 3,55832 silver badges50 bronze badges 3- Ok might want to post some code, explain more what you are trying to do. – Dejan.S Commented Feb 17, 2012 at 9:48
- In any case this is invalid HTML. The anchor element may only contain other inline elements. – cillierscharl Commented Feb 17, 2012 at 9:50
- @Dejan i did edit my question. – Jignesh Rajput Commented Feb 17, 2012 at 9:56
2 Answers
Reset to default 4you could do
$('div.ms-inputuserfield').wrap('<a href="#"/>');
EDIT - fiddle here http://jsfiddle/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./wrap/
Thanks