Bug Tracker

Ticket #4873: empty_anchor_attribute_selector.htm

File empty_anchor_attribute_selector.htm, 1.2 KB (added by mqj, 13 years ago)

Compares selecting anchors and inputs with empty hrefs and values.

Line 
1<html>
2<head>
3  <script src="jquery-1.3.2.js" type="text/javascript"></script>
4  <script type="text/javascript">
5  //<![CDATA[
6    jQuery(document).ready(function(){ 
7      var empty_href_count_result     = "found " + jQuery("a[href=]").length + " anchors with empty hrefs";
8      var non_empty_href_count_result = "found " + jQuery("a[href!=]").length + " anchors with non-empty hrefs";
9      var empty_value_count_result     = "found " + jQuery("input[value=]").length + " inputs with empty values";
10      var non_empty_value_count_result = "found " + jQuery("input[value!=]").length + " inputs with non-empty values";
11      jQuery('#results').html(empty_href_count_result + "; " + non_empty_href_count_result + "<br />" +
12        empty_value_count_result + "; " + non_empty_value_count_result
13      );
14    });
15  //]]>
16  </script>
17</head>
18<body>
19  <a href="/">anchor with an href to /</a><br />
20  <a>anchor with no href</a><br />
21  <a href="">anchor with explicit empty string href</a><br />
22  <form>
23    <input name="input_with_a_default_value" value="MacGuffin" />
24    <input name="input_with_no_value_attribute" />
25    <input name="input_with_explicit_empty_string_value" value="" />
26  </form>
27  <div id="results"></div>
28</body>
29</html>