我如何从<选择>使用jQuery填充title标记

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

本文关键字:jQuery 使用 填充 title 标记 gt 选择 lt      更新时间:2023-09-26

我有以下选择:

$('#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("");
    });

有没有一种方法可以让用户从下拉列表中选择,选择的"标题"属性将由用户选择的选项中的文本填充?

我不确定你到底在问什么,但我猜你的意思是我做的这个例子?

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());
});