开发者

Editing two fields at the same time

I want to be able to edit the title of an article which is duplicated in a field called "url" which is updated in real time when the user types in the title field...how do I go about this?

开发者_如何学编程

Thanks


You could use jQuery. Have a look at the Manual.

$(function()
{
    $('#field1').keyPress(function()
    {
        $('#field2').val($(this).val());
    });
});


Working demo: http://jsfiddle.net/Wcp3D/

$("document").ready(function ($) {
    $("input").bind('keyup', function() { $("lable").text($(this).val()) } );

});

<input type='text'/>
<label></label>

do you mean something like this?


I don't have my environment configured here at work, but it should be something like that:

$("#url").change(function() {
 document.title = $(this).value();
});


Add a function to the change-event of field one, and update field two in that function:

$('#field1').change( function( ) {
   $('#field2').value( $(this).value( ) );
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜