如何从<select>中选择用jQuery填充title标签?</select>

时间:2012-08-02 09:18:09

标签: javascript jquery

我有这些选择:

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

我有没有办法让它能够让用户从下拉列表中选择select的Title属性填充用户选择的选项中的文本?

1 个答案:

答案 0 :(得分:0)

我不确定你究竟要求什么,但我猜你的意思是这样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());
});