Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

remove next element - jquery

Tags:

html

jquery

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.

like image 320
dotnetrocks Avatar asked Dec 18 '11 14:12

dotnetrocks


1 Answers

<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.

like image 188
John Avatar answered Sep 17 '22 19:09

John