Asked by duncanb7
at 2024-01-11 04:08:09
Point:500 Replies:4 POST_ID:828879USER_ID:11059
Topic:
jQuery;;JavaScript
There're two forms without any id attribute help that I want to.
I want to get html() for all class name ='mesg' in first form only when first form is
onsubmit . I try the following chkvalid() code, but it shows all classname="mesg" even
including second form. the output is "0:A","1:B","2:C","3:D" from console.log
I just want "0:A", "1:B" within first form only .
function chkvalid( obj) {
$( ".mesg" ).each(function( index ) {
console.log( index + ": " + $( this ).html() ); });
So now I try to fix the issue from getting the correct jquery selector such as
$(obj).$(".mesg").each(function( index ) {
console.log( index + ": " + $( this ).html() ); });
but it fail since it is not allowed to use $(obj) and then point to other object inside of
parent object.
How to do that ? and please don't ask me to add id attribute in each form to distinguish both forms.
Please advise
Duncan
I want to get html() for all class name ='mesg' in first form only when first form is
onsubmit . I try the following chkvalid() code, but it shows all classname="mesg" even
including second form. the output is "0:A","1:B","2:C","3:D" from console.log
I just want "0:A", "1:B" within first form only .
function chkvalid( obj) {
$( ".mesg" ).each(function( index ) {
console.log( index + ": " + $( this ).html() ); });
So now I try to fix the issue from getting the correct jquery selector such as
$(obj).$(".mesg").each(function( index ) {
console.log( index + ": " + $( this ).html() ); });
but it fail since it is not allowed to use $(obj) and then point to other object inside of
parent object.
How to do that ? and please don't ask me to add id attribute in each form to distinguish both forms.
Please advise
Duncan