Home > Web Front-end > JS Tutorial > JS/jQuery realizes displaying part of the text by default and clicking the button to display the entire content_javascript skills

JS/jQuery realizes displaying part of the text by default and clicking the button to display the entire content_javascript skills

WBOY
Release: 2016-05-16 17:33:55
Original
1561 people have browsed it
Copy code The code is as follows:





JS implementation Partial text is displayed by default, click the button to display all



Folk The agency predicted the Dali earthquake 3 days in advance and the Seismological Bureau said it was illegal


After the 5.0-magnitude earthquake occurred in Dali Prefecture on the 17th, a post on Weibo predicted that Dali would have a 5.0-magnitude earthquake 3 days ago Weibo posts about the earthquake attracted the attention of many netizens.


The reporter contacted the Weibo blogger, who said that he obtained the forecast information by analyzing data from the official website of the Yunnan Provincial Earthquake Bureau. In response, the Provincial Seismological Bureau responded that it welcomes private institutions to conduct some academic discussions and exchanges with the Bureau, but it is illegal for private institutions to publicly release earthquake forecast information.


Non-governmental organizations’ earthquake predictions are popular among netizens

A strong earthquake will be felt in the region. It is initially identified as a magnitude 5 earthquake with a shallow source. The main locations are Zhaotong in northeastern Yunnan (aftershocks), the junction area of ​​southwest Dali and Tengchong, and the junction area with Myanmar (caused by crustal movement) The border area between Qiaojia County in Yunnan and Ningnan County in Sichuan. "As early as the early morning of April 14, a netizen named "Forecast Center" posted Yunnan earthquake forecast information on Weibo. The Weibo post was forwarded 377 times by netizens. After the 5.0-magnitude earthquake in Dali, well-known netizens such as "Xiao Cong" retweeted the Weibo post. "Kneel down." Well-known netizen "Xiao Cong" said on Weibo.


Before the 5.0-magnitude earthquake in Dali, the "Forecast Center" also published three earthquake forecasts on Weibo, along with a map predicting an earthquake and a picture of Kunming Raw data map of earthquake monitoring points.


This Weibo has been forwarded and praised by some netizens. “Best, forecasting masters are among the private sector, and we are continuing to pay attention.” Netizen “orfila2011” said in a comment; the official Weibo of “Shaanxi Blue Sky Rescue Team” also stated that relevant departments should provide valuable experience and methods in earthquake prediction work among the private sector. enough attention.


The forecast is based on the analysis of data from the Provincial Seismological Bureau


Information from the private earthquake forecast Weibo It shows that the location is in Hubei. “This Weibo has been reporting earthquake prediction information on Weibo a long time ago, but it has always been very mysterious,” said a netizen. Yesterday, the reporter contacted this mysterious private earthquake forecasting agency through Weibo.


How did this private organization obtain earthquake forecast information? The Weibo blogger told reporters that they obtained the forecast information based on the analysis of some earthquake monitoring data in Yunnan Province based on the Yunnan Earthquake Data Sharing Center, the official website of the Yunnan Provincial Seismological Bureau. The reporter found that it is indeed possible to check the preprocessed data of various earthquake monitoring points in Yunnan through this website.


>The Weibo blogger also revealed that analyzing these related data requires a lot of professional knowledge, but no instruments are required. As for the motivation of private organizations to predict earthquakes, the blogger said that it is "material and spiritual." For other information, the blogger was unwilling to disclose more.


Provincial Seismological Bureau: Private exchanges are limited to academic exchanges


"Earthquake prediction and forecasting must comply with the corresponding Laws and regulations." Zhang Junwei, director of the Science and Technology Department and spokesperson of the Provincial Seismological Bureau, said in an interview with reporters that according to our country's laws, it is illegal for any individual or private organization to release earthquake forecast information to the outside world.


The national "Regulations on the Administration of Earthquake Forecasts" stipulates that the long-term earthquake forecasts, medium-term earthquake forecasts, short-term earthquake forecasts and imminent earthquake forecasts of provinces, autonomous regions and municipalities directly under the Central Government are governed by the people of provinces, autonomous regions and municipalities directly under the Central Government. Government release.


Regarding these private earthquake forecasting agencies, Zhang Junwei said that the Yunnan Provincial Earthquake Bureau has always paid attention to and understood them. In addition to the "forecast center" that released the forecast information this time, there are many such private earthquake forecasting institutions and people. Some netizens asked whether cooperation and exchanges between the government and the people could be strengthened. Zhang Junwei said that he has not personally contacted these private organizations at present, but the Earthquake Administration has always been tolerant and open to these private organizations and welcomes them to conduct academic discussions and exchanges with the Earthquake Administration.


"But on the other hand, it is always illegal to publicly release earthquake forecast information. We are also very troubled by these private institutions that publicly release earthquake forecast information, and we are worried that it will bring negative consequences to society. influence."Zhang Junwei believes that citizens and netizens should not rely on earthquake forecast information released by private organizations.



<script> <br>function show(){ <br>var box = document.getElementById("box"); <br>var text = box.innerHTML; <br>var newBox = document.createElement("div"); <br>var btn = document.createElement("a") ; <br>newBox.innerHTML = text.substring(0,200); <br>btn.innerHTML = text.length > 200 ? "...Show All" : ""; <br>btn.href = "## #"; <br>btn.onclick = function(){ <br>if (btn.innerHTML == "...Show All"){ <br>btn.innerHTML = "Collapse"; <br>newBox. innerHTML = text; <br>}else{ <br>btn.innerHTML = "...Show all"; <br>newBox.innerHTML = text.substring(0,200); <br>} <br>} <br> box.innerHTML = ""; <br>box.appendChild(newBox); <br>box.appendChild(btn); <br>} <br>show(); <br></script>
< ;/body>


jQuery plug-in: jquery.limittext.js
Copy code The code is as follows:

/**
* demo:
* 1.$("#limittext").limittext();
* 2.$("#limittext").limittext({"limit":1});
* 3.$("#limittext").limittext({"limit":1,"fill":"...","morefn":{"status":true}});
* 4.$("#limittext").limittext({"limit":1,"fill":"...","morefn":{"status":true,"moretext": "more","lesstext":"hidden part","fullfn":function(){alert("more")},"lessfn":function(){alert("less")}}})
* 5.$("#limittext").limittext({"limit":1,"fill":"...","morefn":{"status":true}}).limit( "all");
* @param {Object} opt
* {
* limit:30,//Number of displayed text
* fill:'...'//Fill when hiding Text
* morefn:{
* status:false,//Whether to enable more
* moretext: "(more)",//The text displayed when hiding part of the text
* lesstext: "(less)", //The text displayed when all text is displayed
* cssclass: "limittextclass", // Enable more CSS class names of A tags
* lessfn: function(){}, // Callback function when less text is displayed
* fullfn:function(){}//Callback function when more text is displayed
* }
* @author Lonely
* @link http: //www.liushan.net
* @Download:http://down.liehuo.net
* @version 0.2
*/
jQuery.fn.extend({
limittext:function(opt){
opt= $.extend({
"limit":30,
"fill":"..."
},opt);
opt.morefn=$.extend({
" status": false,
"moretext": "(more)",
"lesstext":"(less)",
"cssclass": "limittextclass",
"lessfn": function (){
},
"fullfn": function(){
}
},opt.morefn);
var othis=this;
var $this=$( othis);
var body=$this.data('body');
if(body==null){
body=$this.html();
$this.data( 'body',body);
}
var getbuttom=function(showtext){
return ""
showtext
"
";
}
this.limit=function(limit){
if(body.length<=limit||limit== 'all'){
var showbody=body (opt.morefn.status?getbuttom(opt.morefn.lesstext):"");
}else{
if(!opt.morefn.status) {
var showbody=body.substring(0,limit)
opt.fill;
}else{
var showbody=body.substring(0,limit)
opt.fill
getbuttom(opt.morefn.moretext);
}
}
$this.html(showbody);
}
this.limit(opt.limit);
$( "." opt.morefn.cssclass).live("click",function(){
if($(this).html()==opt.morefn.moretext){
showbody=body
getbuttom(opt.morefn.lesstext);
$this.html(showbody);
opt.morefn.fullfn();
}else{
othis.limit(opt.limit);
opt.morefn.lessfn();
}
});
return this;
}
});
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