edit the first option name

后端 未结 2 1238
感情败类
感情败类 2021-01-19 02:54

I have the following code which I do not have access to.

What I want to do is add some text into the first option which is now empty. Text such as \"Select Address\

2条回答
  •  佛祖请我去吃肉
    2021-01-19 03:30

    $('select[name=My_Saved_Billing] > option:first-child')
        .text('Select Address');
    

    If you want to find the empty option(s), not just the first one, use:

    $('select[name=My_Saved_Billing] > option:empty')
    // or
    $('select[name=My_Saved_Billing] > option:empty:first')
    

    To get the option with specific content, use:

    $('select[name=My_Saved_Billing] > option:contains(texthere)')
    

提交回复
热议问题