开发者

How to display value as editable textarea under div with jQuery

HTML

<select name="value" id="value" class="inputbox" size="1">
<option value=""> - Select Value- </option>
<option val开发者_StackOverflowue="red">lamp1</option>
<option value="orange">lamp2</option>
<option value="green">lamp3</option>
</select>
<div id="valuePreview">displays value here</div>

JQuery

$(document).ready(function () {
    $("#value").change(function () {
        var src = $(this).val();
        $("textarea#valuePreview").html($(this).val(result.valuePreview));
    });
});

I try to make the result under id=valuepreview as 'red', 'orange' and 'green' editable like <textarea> in HTML. My jQuery is not good (I'm a newbie) because the script above doesn't work in any browsers, can you guys advise how I can fix the jQuery problems?

Thanks a lot.


<div id="valuePreview" contenteditable="true">....</div>

Also I think you want to do:

$(document).ready(function () {
    $("#value").change(function () {
        var src = $(this).val();
        $("div#valuePreview").html(src);
    });
});

Fiddle: http://jsfiddle.net/maniator/5RuTq/


This seems to work:

$('select').change(
    function(){
        $('#valuePreview').text($(this).find('option:selected').val());
    });

JS Fiddle.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜