jquery

Text in div limited characters, add “Read more” link and show all characters when link is clicked

空扰寡人 提交于 2021-02-04 15:56:51
问题 I've a div with text inside that is displayed using PHP & MySQL, the structure is like this: <div class="description"> <p> Here is a lot of text. </p> </div> I want to display a "Read more" link when the text inside the p-tag is more than 100 characters. I can display the "Read more" link with PHP like this: // strip tags to avoid breaking any html $string = strip_tags($string); if (strlen($string) > 100) { // truncate string $stringCut = substr($string, 0, 100); // make sure it ends in a

Text in div limited characters, add “Read more” link and show all characters when link is clicked

本小妞迷上赌 提交于 2021-02-04 15:56:31
问题 I've a div with text inside that is displayed using PHP & MySQL, the structure is like this: <div class="description"> <p> Here is a lot of text. </p> </div> I want to display a "Read more" link when the text inside the p-tag is more than 100 characters. I can display the "Read more" link with PHP like this: // strip tags to avoid breaking any html $string = strip_tags($string); if (strlen($string) > 100) { // truncate string $stringCut = substr($string, 0, 100); // make sure it ends in a

Detecting a cancel in navigation with Javascript or jQuery

懵懂的女人 提交于 2021-02-04 15:00:07
问题 I was curious if there was a way to detect the user pressing the "stop navigation" button in the browser using javascript (or, even better, jQuery.) For example, if you click a link for a webpage that takes a while to load, you may want to show a spinning loader. But what if the user cancels navigation to the page? Is there anyway to detect that to get rid of the spinning loader that you put? EDIT : I did a bit more research, and there seems to be an onStop event in javascript but, wouldn't

jQuery Prepend before an element

筅森魡賤 提交于 2021-02-04 13:07:40
问题 I have a html structure like this/ <li id="1"></li> <li id="2"></li> <li id="3"></li> <li id="comment-box"></li> now i wanna prepend <li id="4"></li> before comment-box. i am submitting a form from the comment box and once its a success i wanna do the prepend. 回答1: Use before(): $('#comment-box').before('<li id="4"></li>') 回答2: Wouldn't this make more sense?: $('ul#comments_container').prepend('<li id="4"></li>'); or $('<li id="4"></li>').hide().prependTo('Ul#comments_container').slideDown(

jQuery Prepend before an element

六眼飞鱼酱① 提交于 2021-02-04 13:07:35
问题 I have a html structure like this/ <li id="1"></li> <li id="2"></li> <li id="3"></li> <li id="comment-box"></li> now i wanna prepend <li id="4"></li> before comment-box. i am submitting a form from the comment box and once its a success i wanna do the prepend. 回答1: Use before(): $('#comment-box').before('<li id="4"></li>') 回答2: Wouldn't this make more sense?: $('ul#comments_container').prepend('<li id="4"></li>'); or $('<li id="4"></li>').hide().prependTo('Ul#comments_container').slideDown(

Callback function fires too early

 ̄綄美尐妖づ 提交于 2021-02-04 11:29:31
问题 I have this simple function in jQuery: function detailspage(page) { if (page != checkcurrent) { checkcurrent = page; $('div#details').children("div").slideUp("slow", function() { $('div#details').children("div"+page).slideDown("slow"); }); }; }; I have put three <div> 's inside another <div> called <div id="details"> , and they are all slided up and out of sight by default. I now wish to make each of them slide down, when a button for each of them is clicked. Of course a <div> that is open

how to add custom javascript to google sites?

穿精又带淫゛_ 提交于 2021-02-04 10:58:27
问题 How do I get the ability to add/edit the JS on a google sites site? This way I want to use jQuery and jQuery UI to manipulate the look and feel of the site. To be clear, I am not talking about all google sites, just the create-your-own system google has made, called "Google Sites" -> https://sites.google.com/. On the howto page, there is this: Unsupported features The HTML Box tool currently doesn't support the following features: iframes JavaScript code can't create any script, image or link

jquery click event for tablets and touch screen phones

*爱你&永不变心* 提交于 2021-02-04 10:03:22
问题 Ok, I am fairly new to web development for mobile/tablet platforms. I am pretty confident though in developing for a browser environment. My problem is that I don't own any tablet (I am poor so have to fly blind) so it's hard for me to do testing . I'm also quite anxious about the click events not working properly. How can I ensure that click and mousedown jquery events work on tablets/smartphones correctly? Is there any consensus on best practice for click events and tablets/smartphones?

How to add 30 minutes to time as hours and minutes

落花浮王杯 提交于 2021-02-04 08:41:27
问题 I Have a time variable which is f.ex 5:21 . I want to add 30 minutes to it, then whatever result is, I want to add 30 minutes to it. How can I do this in javascript? Ie. I want the interval of 30 min to the time I have. var time = valgraph.datetime; // it's a dynamic time var times = time.replace('Z', ''); var res = times.substr(11, 5); // time AS 5:20 回答1: Try this way to add minutes to your time string. function addMinutesToTime(time, minsAdd) { function z(n){ return (n<10? '0':'') + n; };

Bootstrap modal on hiding adds padding-right to html body

无人久伴 提交于 2021-02-04 08:35:42
问题 I am hiding and showing modal in this sequence: when I click on import button it will target modal with id="import-actionpopup" then I have two other button Append, and override when I upload file and select option then this import-actionpopup will be closed and then I have two other modal with id="warningOverrideAction" which will be openned on overrideButton button click and other modal with id="appendAction" which will be openned on appendButton click. Now when I hide my