开发者

Systematic HTML tags validation

开发者 https://www.devze.com 2023-01-30 19:26 出处:网络
Is there an offline tool that can verify whether certain tags possess particular attributes? I\'m looking for something that can verify that all:

Is there an offline tool that can verify whether certain tags possess particular attributes?

I'm looking for something that can verify that all:

Does tidy have an obscure option where you could specify such things?


simply and quickly you can do your validations like this if jQuery is available on your page.


    $('form').each(function(){
        if ($(this).attr('name') === undefined) {
            alert('There is at least one form with no name.');
        }
    });
    $('div').each(function(){
        if ($(this).attr('id') === undefined) {
            alert('There is at least one div with no id.');
        }
    });


also this is a non-jQuery solution example

var arr = document.getElementsByTagName('div');
var flag = false;
for (var i = 0, len = arr.length; i < len; i++) {
    if (arr[i].getAttribute('id') == null) {
        flag = true;
        break;
    }
}
if (flag) {
    alert('There is at least one div with no name.');
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号