简体   繁体   中英

How can I make a choice from a <select> populate the title tag with jQuery?

I have these selects:

$('#AccountID, #PageID, #TopicID')
    .focus(function () {
        $('option[value="99"]', this).remove();
        store.setItem($(this).attr('id'), $(this).val());
    })
    .change(function () {
        store.setItem($(this).attr('id'), $(this).val());
        $('#detailData').html("");
    });

Is there a way I can make it so that if a users select from the drop down that the Title attribute of the select is populated with the text from the option that the user selected?

Im not sure what you are asking for exactly, but Im guessing you mean something like this example Ive made?

html:

<p id="title">1</p>
<select id="dd">
    <option>1</option>
    <option>2</option>
    <option>3</option>
</select>

js:

$('#dd').change(function() {
  $('#title').text($(this).val());
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM