मैं निम्नलिखित कोड है कि हर बार एक तत्व परिवर्तन मेरी वेब फार्म के भीतर होता है काम करता है:jQuery का उपयोग करें और कैसे 'इस' पर कब्जा करने की बदली हुई फ़ॉर्म तत्व मूल्य
<!--
jQuery.support.cors = true; // needed for ajax to work in certain older browsers and versions
$(document).ready(function(){
$(this).change(function(){
alert('form element changed!');
});
}); // end .ready()
//-->
क्या मैं के साथ संघर्ष कर दिया गया है फॉर्म फील्ड तत्वआईडी, नाम और बदली हुई मूल्य जब परिवर्तन घटना शुरू हो रहा है पर कब्जा करने के लिए कैसे है।
क्या कोई इस पर मेरी सहायता कर सकता है?
धन्यवाद!
** JavaScript फ़ाइल **
// Sarfraz
$(this).change(function(){
var id, name, value;
id = this.id, name = this.name, value = this.value;
alert('id=' + id); // this returns 'undefined'
alert('name=' + name); // this returns 'undefined'
alert('value=' + value); // this returns 'undefined'
});
//
// rjz
$(this).change(function(){
var $this = $(this),
id = $this.attr('id'),
name = $this.attr('name'),
value = $this.val();
alert(id); // this returns 'undefined'
alert(name); // this returns 'undefined'
alert(value); // this returns blank
});
// Jamie
$(this).change(function(){
var id = $(this).attr('id');
var name = $(this).attr('name');
var value = $(this).attr('value');
alert('id=' + id); // this returns 'undefined'
alert('name=' + name); // this returns 'undefined'
alert('value=' + value); // this returns 'undefined'
});
//
//James Allardice
$(this).change(function(e) {
var elem = e.target;
alert('elem=' + elem); // this returns 'objectHTMLTextAreaElement'
});
//
// Surreal Dreams
$("#my-form input").change(function(){
alert('form element changed!');
var value = $(this).val();
var id = $(this).attr("id");
var name = $(this).attr("name");
alert(id); // nothing happens
alert(name); // nothing happens
alert(value); // nothing happens
});
//
//Jamie - Second Try
$('.jamie2').each(function() {
$(this).change(function(){
var id = $(this).attr('id');
alert(id); // nothing happens
});
});
//
आपके उदाहरण में 'यह' क्या है? – jrummell
"यह" जावास्क्रिप्ट में एक आरक्षित शब्द है, सही? –
हां, लेकिन इसका अर्थ प्रासंगिक है। – jrummell