简体   繁体   中英

Making text appear while typing - why does this not work in Internet Explorer

I have a form. On this form there's an input which has javascript attached so that whatever's typed into the input appears in a div elsewhere on the page.

I have two solutions for doing this. One uses keyup and works on all browsers, the other uses onpropertychange (which looks better but doesn't seem to work on Internet Explorer 7 & 8 (works on 9).

Here's the codes:

$('#CampaignTitle').keyup(function() {
  $('#titleBar').text(this.value);
}); 

and

$('#CampaignTitle').bind("onpropertychange input", function() {
  $('#titleBar').text(this.value);
});

How come the 2nd one doesn't work on ie7 and ie8?

Is it something to do with jQuery? I'm new at Javascript

I'm using virtual machines to test the different versions which I've never done before but everything else works so surely it's not that?

您是否尝试使用.change()

Use only "propertychange" , without the leading "on".

It works in IE9 because IE9 supports the input -event

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