javascript - Change display and icon when click on <a> element -
i want know how change display style , element class when click on element: , i'm loading " jquery.min.js version: 2.1.4 " , " bootstrap.min.js "
before click on element:
<ul class"nav navbar-nav" > <li class="nav-item search"> <!-- element --> <a class="nav-link search-toggle" id="nav-link-search" href="#" title="search posts"> <i class="fa fa-fw fa-search"></i> <span class="sr-only"> search </span> </a> </li> </ul> </div> <progress class="nav-progressbar" max="100" title="how of page have seen far. hold , drag change page position." value="0"></progress> </nav> <div class="search-area"> <div class="container"> <div class="search-area-input"> <input placeholder="search articles" type="text"> </div> <div class="search-area-results index"> <ol class="article-index-list"></ol> </div> </div> </div>
and after click on element:
<nav class="nav navbar-nav"> <li class="nav-item search"> <!-- element --> <a class="nav-link search-toggle" href="#" title="search articles"> <i class="fa fa-fw fa-times" title="close search"></i> <span class="sr-only"> search </span> </a> </li> </ul> </div> <progress class="nav-progressbar" max="100" title="how of page have seen far. hold , drag change page position." value="0"></progress> </nav> <div class="search-area" style="display: block;"> <div class="container"> <div class="search-area-input"> <input placeholder="search articles" type="text"> </div> <div class="search-area-results index"> <ol class="article-index-list"></ol> </div> </div> </div>
$("a").click(function(){ var =$(this); i.removeattr('title'); i.attr('title','search articles'); i.removeattr('id'); var j = $('i.fa-search'); j.removeattr('class'); j.attr('class','fa fa-fw fa-times'); j.attr('title','close search'); $('.search-area').css('display',"block"); });
if u want (display:none) again
$("a").click(function(){ var =$(this); i.removeattr('title'); i.attr('title','search posts'); i.attr('id','nav-link-search'); var j = $('i.fa-times'); j.removeattr('class'); j.attr('class','fa fa-fw fa-search'); j.removeattr('title'); $('.search-area').css('display',"none"); });
Comments
Post a Comment