Home > Web Front-end > JS Tutorial > js common functions

js common functions

巴扎黑
Release: 2016-11-25 15:05:47
Original
922 people have browsed it

 
 
 
     
     
     
     
     
 
 

show 

money div span em li canvas vide audio
 

 
 
     
  • 自由
  •  
  • 字符
  •  
  • 数字
  •  
 
 


<script> <br>/*Remove spaces and return the length of the string*/ <br>var str = $("#str" ).html(); <br>var ss = str.replace(/s/g,""); <br>document.write(ss.length+"Return the length of the string</br>"); <br>var indexo =ss .indexOf("li"); <br>document.write(indexo+"Return the position where li first appears</br>"); <br>var srchref = ss.link("http://www.w3cschool.cc"); <br>document.write(srchref+"Add link</br>") <br>var mud = ss.match("li"); <br>document.write(mud+"Return the string that exists, return null</br>" ) <br>var query = ss.charAt(4); <br>document.write(query+"Return the string with the specified subscript</br>") <br>var con = ss.concat("Hahaha"); <br>document.write (con+ " " +"Concatenate two strings</br>"); <br>var sea =ss.search("li"); <br>document.write(sea+"Return the subscript of the string exists, does not exist Return -1</br>") <br>var sli = ss.slice(1,4); <br>document.write(sli+"Intercept and return the string</br>") <br> $(document).ready( function(){ <br>/* $(".submin").click(function(){ <br>$("#str").toggle();toggle hidden <br>toggle(function(){},function(){} ); <br>Single show and hide show(),hide(); <br>Get the matching first click to execute the first function and the second click to execute the second function <br>})*/ <br>/* $(". submin").click(function(){ <br>$("#str").fadeToggle(1500); <br>Separate hiding and display fadeOut() fadeIn() <br>Slow hiding and display are similar to the usage of the toggle() function <br>} )*/ <br>/* $(".submin").click(function(){ <br>$("#str").slideToggle(1500); <br>Individual sliding up and down to hide and display slideDown(), slideUp() <br>Up and down The usage of sliding hidden switching is similar to the fadeToggle() function <br>})*/ <br>/* $(".submin").click(function(){ <br>$(".stringname").animate({left:'250px' , opacity:'0.5',height:'150px', width:'150px'},1500); <br>animation <br>});*/ <br>/* $(".ClassNameToBeRemoved").click(function(){ <br>$ (".stringname").slideDown(5000); <br>Slide down the panel! <br>}); <br> $(".submin").click(function(){ <br> $(".stringname").stop(); <br> Stop sliding the panel down <br> });*/ <br>/* text() - Set or return the text content of the selected element <br>html() - Set or return the content of the selected element (including HTML tags) <br>val() - Set or return the value of a form field <br>attr() method is used to get the attribute value. */ <br><br>/* $("#str").click(function(){ <br> alert($("#stringname").attr("class")); <br>});*/ <br>/* append( ) - insert content at the end of the selected element value <br>prepend() - insert content at the beginning of the selected element value <br>after() - insert content after the selected element border <br>before() - insert before the selected element border Content*/ <br>/* $("#str").click(function(){ <br> $("#stringname").append("<span>Compression</span>"); <br>}); <br> $("#str").click(function(){ <br> $("#stringname").prepend("<span>Dema</span>"); <br>}); <br>$("#str ").click(function(){ <br> $("#stringname").after("<span>Timo</span>"); <br>}); <br>$("#str").click( function(){ <br> $("#stringname").before("<span>Glory</span>"); <br>});*/ <br><br>/* remove() - Remove the selected element (and Sub-element) <br>empty() - Remove sub-elements from selected elements*/ <br>/* $("#submin").click(function(){ <br> $("#stringname").remove(); <br>} );*/ <br>/* $("#submin").click(function(){ <br> $("#stringname").empty(); <br>});*/ <br>}); <br>//.append( i); Append after the element value <br>//queryarryl.find("a"); Return all sub-elements under queryarryl that are a; <br>//on() add event; <br>//index(this); Return the current element subscript <br>//queryi.eq(index).removeClass("active").hide(); Delete the class style and hide it according to the subscript returned by index <br><br><br>$(function(){ <br>var queryarryl = $(".arrayl" ); <br>var querya = queryarryl.find("a"); <br>var queryem = querya.find("em"); <br>var queryi = querya.find("i"); <br>queryi.hide(); <br>queryem .on('click',function(){ <br>var index = queryem.index(this); <br>if(queryi.hasClass("active")){ <br>queryi.eq(index).removeClass("active"). hide(); <br>}else{ <br>queryi.eq(index).addClass("active").show().append("qq"); <br>} <br><br>}); <br>var querytitle=$(".title "); <br>var titleli = querytitle.find("li") <br>titleli.on('click',function(){ <br>var index = titleli.index(this); <br>queryarryl.hide(); <br>titleli.removeClass ("active") <br>titleli.eq(index).addClass("active"); <br>queryarryl.eq(index).show(); <br>}); <br><br>}) <br>//Execute event real-time monitoring when input changes <br><body> <br><div class="imges"> <br><ul> <br><input type="text" id="idName"/> <br></ul> <br></div> <br><br></body> <br><script src="js/jquery-1.7.2.min.js"></script>
<script> <br>$(function(){ <br>$("# idName").on("input propertychange",function(){ <br>alert("changed"); <br>}) <br>}); <br>/*Jquery needs to bind events when splicing html statements, which cannot be done in the spliced ​​statements. If you add an in-line binding event, it will not be clickable. At this time, you can use this method to get the div of the parent class or go to the in-line id*/ <br> $("#sureWin").on("click","#sectionid",function() { <br> $("#section").hide(); <br>}) <br>/*To be added later*/ <br></script>


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template