Reputation: 2727
I would like remove next element of a selected element. Here, I would like to remove "div" with css class "xqh_Mandatory_icon".
<div class="xqh_Field">
<nobr>
<input name=
"ctl00$objContentPageTag$spzContactInformation$txt_sContactFirstName$txt" type="text"
size="25" id=
"ctl00_objContentPageTag_spzContactInformation_txt_sContactFirstName_txt" class=
"xqh_TextBox_Edit validate_txt_sContactFirstName" style=
"width:150px;margin-right:0px;" />
</nobr>
<div class="xqh_Mandatory_icon"></div>
</div>
I tried with this code
$('.xqh_TextBox_Edit.validate_txt_sContactFirstName').next().remove('xqh_Mandatory_icon');
but it didn't work.
Upvotes: 7
Views: 23342
Reputation: 6268
<html>
<head>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.1.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$('.xqh_TextBox_Edit.validate_txt_sContactFirstName').next().remove();
});
</script>
</head>
<body>
<div class="xqh_Field">
<input name="ctl00$objContentPageTag$spzContactInformation$txt_sContactFirstName$txt" type="text" size="25" id="ctl00_objContentPageTag_spzContactInformation_txt_sContactFirstName_txt" class="xqh_TextBox_Edit validate_txt_sContactFirstName" style="width:150px;margin-right:0px;">
<div class="xqh_Mandatory_icon">
yep
</div>
</div>
</body>
</html>
Set it to execute the code when the document is ready, also you were missing the period for the second class name. You had a space there instead.
Upvotes: 17