jquery

Why it doesn't replace correctly if I run multiple replace checks?

▼魔方 西西 提交于 2021-01-28 19:11:01
问题 I am replacing smile character like :) to images. If I use only var yorum4 = "hello :)"; yorum4 = yorum4.replace(/(:\))/g, "<img class='smileys' src='smile.png' \/>"); It replaces correctly. However, when I use this for multiple replaces, yorum4 = yorum4.replace(/(:\))/g, "<img class='smileys' src='smile.png' \/>"); yorum4 = yorum4.replace(/(:\()/g, "<img class='smileys' src='smile1.png' \/>"); yorum4 = yorum4.replace(/(;\))/g, "<img class='smileys' src='smile2.png' \/>"); It corrupts and

jQuery change data attribute value

不打扰是莪最后的温柔 提交于 2021-01-28 19:09:48
问题 Hello I have the folowing HTML element : <li class="total_payment" data-basetotal="0.00"> <span> <h5>Total</h5> </span> </li> I want to change the data-basetotal value from 0.00 to 50.00 with jQuery jQuery v1.7.2 using : $(document).ready(function(){ $('.total_payment').attr('data-basetotal', '50.00'); }); but it is not working , how can I change the value please? Thanks 回答1: Try to use $('.total_payment').data('basetotal', '50.00'); 来源: https://stackoverflow.com/questions/32742738/jquery

jQuery Isotope filtering: add a class when there are no items in a data-category in the grid

余生长醉 提交于 2021-01-28 19:09:47
问题 I have an isotope layout with sorting of grid items by a filter; and when items are sorted by button, the items in the grid that are not in the selected data-category have their CSS opacity changed to .25. The problem is that when the grid is complete - either on initial page load or after an "arrangeComplete" by the button action of sorting - there are certain data-categories that have no items in the grid. This means that some sorting buttons are still clickable even though they don't sort

Why does jQuery's ajax automatically run scripts?

北战南征 提交于 2021-01-28 19:05:36
问题 I noticed recently that if jQuery ajax is called right after injecting jQuery into an inner iframe, jQuery loses its functions - like jQuery(..).dialog(), .draggable, and any other plugins. If the ajax call is commented out, the jQuery works fine. Is this a known bug, or something I'm doing wrong? This problem can be seen in this file, with jQuery in the same directory: <html> <head> <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" /> <script src=

How to know whether solr server is running or not

不羁的心 提交于 2021-01-28 19:04:56
问题 I've got this problem that I can't solve. Partly because I can't explain it with the right terms. I'm new to this so sorry for this clumsy question. Below you can see an overview of my goal. I'm using Magento CE 1.7.0.2 & Solr 4.6.0. var url1 ="http://127.0.0.1:8080/solr/select?q=iphon&wt=json&json.wrf=?"; $.getJSON(url1,function(result){ // my logic }); when the Solr Server is Running means this script is working fine.But if my Solr Server is Not Running means it'll not work. But my goal is

jquery - allow only negative, positive or decimal number validation

女生的网名这么多〃 提交于 2021-01-28 19:03:19
问题 I need a javascript/jQuery routine that validates a string to allow only negative, positive or decimal numbers(ex. -1 or -41.02 or 20 or 2.20 or 10.05) 回答1: function validate(str){ var fvalue = parseFloat(str); return !isNaN(fvalue) && fvalue != 0; } 回答2: The regular expression given below solves the issue, it works for -ve decimal numbers. ^-?[0-9]{0,4}(.^-[0-9]{1,4})?$|^(100)(.^-[0]{1,4})?$ 回答3: One way to do this is to parse the value and see if you get a valid number. You can also use

How to fix search field below header in submenu of jQuery mobile

懵懂的女人 提交于 2021-01-28 19:00:37
问题 I have a main menu and a click on the main menu opens a sub menu with multiple items. Below the sub-header is a search-field . I want to fix the search-field below the sub-header so that it doesn't scroll with all the options any longer. I am not sure whether this can be done with CSS. I didn't get it to work by adding overflow-y: scroll to .ui-input-search . $(document).on("pagecreate", "#demo-dialog", function(e) { var form = $("<form><input data-type='search'/></form>"), page = $(this); $(

Callback function for video.js?

妖精的绣舞 提交于 2021-01-28 19:00:11
问题 I'm using the video.js plugin. I'm using ajax to load in another bunch of videos from another page but I want to call the javascript again to perform the skinning again. Is there a callback function I can use after my ajax has finished loading in the html? To be specific I'm after the actual function name (if there is one) that video.js has made. ie the javascript which runs to dress up the videos. 回答1: Ajax has a success call back you may be able to use. $.ajax({ type: "GET", url: url,

Bootstrap table row clickable with buttons in row

孤人 提交于 2021-01-28 18:59:11
问题 I have some table rows which I want to be clickable. I found out how to do that but now I have a problem with buttons within the row. The problem is that when I click on the button it opens the link of the parent row. JS : $('.table tr.row-link').each(function(){ $(this).css('cursor','pointer').hover( function(){ $(this).addClass('active'); }, function(){ $(this).removeClass('active'); }).click( function(){ document.location = $(this).attr('data-href'); } ); }); HTML of one row: <tr class=

Slide toggle other submenus when a submenu opens

风流意气都作罢 提交于 2021-01-28 18:55:46
问题 Hello I have a mobile menu with sub-menus. I have it set up and working properly but I would like to add another feature. I want it so when a sub-menu is open, and a user clicks to open another sub-menu, the first sub-menu collapses (or closes). Here is the basic html structure: <ul id="menu-main-menu"> <li class="menu-item-has-children"><a>parent link</a> <ul class="sub-menu"> <li><a href="#">child link</a></li> <li><a href="#">child link</a></li> </ul> </li> <li class="menu-item-has