jquery Element List Traversal method

Source: Internet
Author: User
Tags prev
$ (selector). each (function (index,element))
You encounter a property saved by a Drop-down list task at work and the default assignment to the Drop-down list, but the selected property of the list is ' cur ', where you need to select a row record based on the Text property comparison
<Liclass="Item Clearfix"id="cn"style="Display:None"> <Divclass="Label_cont"> <Divid="cn"class="Select_drop edm_select_simulate01"name="Subscription"> <Divclass="D_sselect"> <spanclass=' Showtxt '></span> <Iclass="Triggle_icon"></I> </Div> <Divclass="D_sselect_con"> <Divclass="select_list"> <C: ForEachvar= "S"Items="${11}"> <ahref="javascript:;"class="Options_item"data-val="${S.value}" >${S.text}</a> </C: ForEach> </Div> </Div> <Divclass="Icon_error_tips"> <span>!</span> <P>error Tips </P> </Div> </Div> </Div> </Li>

$ ("#cn"). Find ('. D_sselect_con '). Prev ('. D_sselect '). Find ('. Showtxt '). Text (TASKOBJ.MAILTYPESTR);
$ (' #cn '). Find ('. Options_item '). Each (function() {
    if($ (). Text () ==taskobj.mailtypestr) {
        $ ( this). addclass (' cur ');
    }
);
$ ("#cn"). Find ('. D_sselect_con '). Prev ('. D_sselect '). Find ('. Showtxt '). Text (TASKOBJ.MAILTYPESTR);
This line can only display text content, but the control still does not have a selected value;
 so you use each traversal alignment and then assign the property ' cur ' 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.