html-attributes

How can I show/hide elements based on multiple-attributes and multiple-attribute-values?

Hi, I would like to view/hide divs on a page, based on attribute filters. I've made several attributes which can have multiple values. Users can choose which ones they want to see displayed. I can't get the right algorythm (or I don't know which Javascript/jQuery function to use). The following obviously doesn't work. I'm first showing...

PHP - split a string of HTML attributes into an indexed array

Hi, I've got a string with HTML attributes: $attribs = ' id= "header " class = "foo bar" style ="background-color:#fff; color: red; "'; How to transform that string into an indexed array, like: array( 'id' => 'header', 'class' => array('foo', 'bar'), 'style' => array( 'background-color' => '#fff', 'color' => 'red' ...

Dealing with checkboxlists and radiobuttonlists when POSTing forms

What is the right way of creating and processing a group of related controls on posted forms? From using ASP.NET MVC I see a standard option is to create a number of inputs and assign the same "name" attribute value to them. Like this: <input name="OrderOptions" type="checkbox" value="1" /> <input name="OrderOptions" type="checkbox" va...

HTML Element, Custom Client Event

I have a composite control which emits HTML that looks like this <span id="myControl"> <select id="myControl_select"> <option value=""></option> <option value="1">Item 1</option> <option value="2">Item 2</option> </select> </span> I would like the parent span control to fire an event when the contained drop dow...

Getting title attribute with jQuery

Hello assume that I have this list: <ul id="carousel"> <li><a title="hey"><img src="image.png"/></a></li> </div> And now my jQuery script: $(function() { $("#carousel a").click(function(){ var url = $(this).attr('title'); alert(url); }); }); This doesn't work, it works for other attributes such as "alt...

Speed difference between anonymous class and IDictionary<string,object> for htmlAttributes in ASP.NET MVC

I am trying to optimize my ASP.NET MVC application using some techniques that include URL generation tweaking a la: http://www.chadmoran.com/blog/2009/4/23/optimizing-url-generation-in-aspnet-mvc-part-2.html If the speed difference is so large between using RouteValueDictionary in place of anonymous classes, then should I also look to u...

In ASP.NET MVC 2 RC 2, Is it possible to remove the name="" attribute and leave the id attribute?

If you do this in Asp.Net MVC 2 RC 2: <% for (int count = 0; count < Model.Students.Count; count++ ) { %><%= Html.EditorFor(m => m.Students[count]) %><% } %> where Students is a List<Student>, and it produces this: <input class="text-box single-line" id="Students_0__Name...

What's the best HTML attribute to use to store information for jQuery to parse?

Must Support IE6 and must Validate vs XHTML Strict 1.0! This is tricky to explain... I'm using a generic class name to initiate a plugin feature on an associated element. I also want to have options associated with the element stored in an attribute as well. <a href="url.com" class="popup" rel="900x900" >My Link</a> With this, jQue...

Do search engines add weight for microformats?

For example, if I had <a href="http://www.example.com"&gt;My friend Bill</a> or <a href="http://www.example.com" rel="friend">My friend Bill</a> Will Google for example give extra weight to the second because I specified they are a friend? ...

What are the javascript performance tradeoffs in adding id's to dom elements?

For example, I have a website which has a dynamically-generated segment of its dom which looks roughly like this: <div id="master"> <div class="child"> ... </div> <div class="child"> ... </div> <div class="child"> ... </div> ... <div class="child"> ... </div> </div> There might be hundreds of child elements in this manner, a...

COMPLETE list of HTML tag attributes which have a URL value?

Besides the following, are there any HTML tag attributes that have a URL as their value? href attribute on tags: <link>, <a>, <area> src attribute on tags: <img>, <iframe>, <frame>, <embed>, <script>, <input> action attribute on tags: <form> data attribute on tags: <object> Looking for tags in wide usage, including non-standard tags ...

Alt attribute encoding with JavaScript

Hi, Html entities must be encoded in alt attribute of an image in HTML page. So <img id="formula" alt="A &rarr; B" src="formula.png" /> will work well. On the other hand, the same JavaScript code will not work document.getElementById('formula').alt = 'A &rarr; B'; and will produce A &rarr; B instead of A B. How to do it through...

Django: How do I add arbitrary html attributes to input fields on a form?

I have an input field that is rendered with a template like so: <div class="field"> {{ form.city }} </div> Which is rendered as: <div class="field"> <input id="id_city" type="text" name="city" maxlength="100" /> </div> Now suppose I want to add an autocomplete="off" attribute to the input element that is rendered, how would ...

How bad is it to add other attribute to an element or what other options are there?

I have an element where I'm already using the rel attribute, but I would also like to add another attribute that I'll be using in JavaScript. <a href="/" rel="blah" foo="bar">Link</a> Is it alright to add other attributes? Or is there a better option? ...

Cannot set title and alt attributes in my img using javascript

I'm using the Google Image Search API, and largely copied this code, which builds the search results in my page. for (var i = 0; i < results.length; i++) { // For each result write it's title and image to the screen var result = results[i]; var linkContainer = document.createElement('div'); var title = document.createE...

What's a good way to attach a numeric value to an element?

I'd like to have some HTML like this: <div id="div0" someAttr="0" class="shown">Some stuff</div> <div id="div1" someAttr="1">Some stuff</div> <div id="div2" someAttr="2">Some stuff</div> <div id="div3" someAttr="3">Some stuff</div> And then manipulate it like this: $('div').click(function() { if($(this).someAttr > $('div.sho...

SEO - Special chars in title and alt attributes

Hello. Are special chars like &aacute; in alt and title attributes a problem for SEO? Thanks! Diego ...

what is the meaning of jquery random attributes in html ?

what is the meaning of these jquery random attributes in html and how jquery use them any ideas please ?? ...

When should I use the name attribute in HTML4/HTML5?

I know by reading the W3C documention for HTML4.01 and HTML5 that the "name" attribute originally existed as a property of the <a> tag to permit people to link to an anchor point within a document. However, now that all major browser venders allow linking to any html element within a document via the "id" attribute, is there still any ...

Are single/double quotes allowed inside HTML attribute values ?

I'm trying to set attribute value that contains a single quote: var attr_value = "It's not working"; var html = "<label my_attr='" + attr_value + "'>Text</label>"; $('body').html(html); However, I get the following result: <label working="" not="" s="" my_attr="It">Text</label> How could I fix this ? Are double quotes allowed insi...