javascript - How do i add different classes to different elements in a div? -


i have div

<div id="test1"> <a id="hello1"> one</a> <a id="hello2"> two</a> <a id="hello3"> three</a> </div> 

i using templates , backbone.js . before rendering view want check if device iphone or ipad have function. if ipad want add seperate classes each anchor tag. i.e class1 hello1 , class2 hello2 etc. have 3 elements. new @ can pls tell me how can using jquery/javascript .

if chance there someother info should providing pls let me know. have view.js , routing.js along this. tried using.

$("#hello1").addclass("class1"); 

however did not work . appreciated. thanks

edit - view file

define([ "jquery", "backbone", "baseview", "template" ], function ($, backbone, baseview) {  "use strict";  var gohomeview = baseview.extend({      initialize: function () {         this.constructor.__super__.initialize();          this.events = _.extend({}, this.globalevents, this.events);         this.delegateevents();     },      render: function () {          var context = {                 pagename: 'go home'             },             partials = {                 header: this.globalpartials.header,                 tabbar: this.globalpartials.tabbar             };            $(this.el).html(templates["go-home"].render(context, partials));         return this;     }  });  return gohomeview; 

});

missing ending quote.

$("#hello1").addclass("class1"); 

Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -