मैं कक्षा required
के साथ आइटमों के संग्रह पर पुन: प्रयास करने की कोशिश कर रहा हूं। मुझे लगता है कि मुझे $.each
फ़ंक्शन गलत तरीके से उपयोग करना होगा।
function required(address) {
//object to hold elements not passing validation tests
var pass = true;
$('.required').each(function(index, elem){
console.log(elem);
//check if it has the class indicating it is an email
if (elem.hasClass('re')) {
var validEmail = validateEmail(address.email);
if (!validEmail){
$(this).addClass('nv');
}
}
});
}
मुझे लगता है कि कंसोल में तत्व <input type="text" id="name_input" class="pr required">
और है तो त्रुटि Uncaught TypeError: Object #<HTMLInputElement> has no method 'hasClass'
कैसे उस वस्तु hasClass विधि नहीं हो सकता?
नहीं करना चाहिए यह जा सकता है? –