开发者

Systematic HTML tags validation

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜