javascript - extract the value of id as a string using jquery -


below code

<div class="row-fluid" id="header"></div>      <div class="tab-content">         <div class="tab-pane active" id="tab2">             <div class="row-fluid">                 <div class="span9 offset1">                     <header id="second">                         <strong>users</strong>                 </div>                 <div class="span2">                 <div class="tabbable" align="center">                     <ul class="nav nav-pills">                         <li class="active"><a href="#mobile" data-toggle="tab"><strong>mobile</strong>                         </a>                         </li>                         <li><a href="#bo" data-toggle="tab"><strong>bo</strong>                         </a>                         </li>                      </ul>                 </div></div></div> 

actually want extract id bo string. suppose there function called

function display(type){   if (type== /* here want extract id bo */) } 

how can want equate id bo string type. using jquery or javascript.

function dislpay(type) { 

/* here below in place of type have pass ids mentioned above using if function how can code written in javascript*/

            $.get('http://something' + **type**, function(data) {                  ( var = 0; < data.user.length; i++) {                     var html = '';                     if (i == 0)                         html = '<li class="active"><a href="#userdetails" data-toggle="tab" onclick=\"loaduserdetails(\''                                 + data.user[i].id                                 + '\')\">'                                 + data.user[i].id                                 + '</a></li>';                     else                         html = '<li><a href="#userdetails" data-toggle="tab" onclick=\"loaduserdetails(\''                                 + data.user[i].id                                 + '\')\">'                                 + data.user[i].id                                 + '</a></li>';                      $("#users").append(html);                 }                 users = data;              })              .error(function(xhr, status, error) {                 alert("error");                 alert(xhr.responsetext);                 var err = eval("(" + xhr.responsetext + ")");                 alert(err.message);             });           } 

function display(lnk) {     if($(lnk).attr('href') == '#bo') {      console.log(true);     } }  $(document).ready(function(){     $('.nav-pills a').each(function(k,v) {         display(this);     }); }); 

demo: http://jsfiddle.net/cmexb/


Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -