Get label for input field

前端 未结 10 560
野趣味
野趣味 2021-01-11 09:53

I\'m doing a validation with Jquery and need to get the $label from each element with their own label. Now the alert() gives med [object object]. The best thing for me here

10条回答
  •  花落未央
    2021-01-11 10:11

    With JQuery, you can find all the labels linked to the input with $(input).labels();

    $('input').each( function() {
        var $labels = $(this).labels();
        $labels.each(function(index, element){
            alert($(element));
        });
    });
    

提交回复
热议问题