jquery

Why does jQuery.change() only trigger when I leave the element?

拥有回忆 提交于 2021-02-07 18:17:55
问题 I have a textarea element and I want to print the number of characters written, above the textarea, as I'm typing. The HTML looks like this: <p id="counter"></p> <textarea id="text"></textarea> and the javascript: jQuery( "#text" ).change( function(){ var numberOfChars = jQuery( "#text" ).val().length; jQuery( "#counter" ).html( numberOfChars ); }); But the counter only "updates" when I click outside the textarea. Why is that? I want the counter to update on the fly as I'm writing. 回答1: this

jQuery datatables filter row with specific class

白昼怎懂夜的黑 提交于 2021-02-07 18:16:26
问题 I am working on a jQuery Datatable project where I need to filter the data based on specific row classes. I'm adding classes to my rows upon row creation based on a condition. I'm trying to figure out a way for my user to click a button which would apply a filter that only displays rows that contain a specific class. I've tried a few different solutions but I can't seem to make it work. Does anyone know how to do this correctly? Here is the JSFiddle $('#table').DataTable({ data: data, columns

Backslashes in JSON string

前提是你 提交于 2021-02-07 18:15:37
问题 I'm not familiar with this format: {"d":"{\"Table\":[{\"pCol\":12345,\"fCol\":\"jeff\",\"lCol\":\"Smith\",\"dId\":1111111,\"tDate\":\"\\/Date(1153033200000-0700)\\/\"}]}"} I'm using Newtonsoft to serialize my DataSet that I'm returning from my ASP.Net webservice. The above JSON string is what Firebug is returning. I have checked this JSON using jsLint and it is good. In firebug I see the JSON data and my first alert('success'); However when I try to alert(msg.d.Table); I get nothing. Not an

Backslashes in JSON string

ε祈祈猫儿з 提交于 2021-02-07 18:15:10
问题 I'm not familiar with this format: {"d":"{\"Table\":[{\"pCol\":12345,\"fCol\":\"jeff\",\"lCol\":\"Smith\",\"dId\":1111111,\"tDate\":\"\\/Date(1153033200000-0700)\\/\"}]}"} I'm using Newtonsoft to serialize my DataSet that I'm returning from my ASP.Net webservice. The above JSON string is what Firebug is returning. I have checked this JSON using jsLint and it is good. In firebug I see the JSON data and my first alert('success'); However when I try to alert(msg.d.Table); I get nothing. Not an

JQUERY How to disable not-allowed cursor while dragging?

坚强是说给别人听的谎言 提交于 2021-02-07 18:13:31
问题 I've got issue with the not-allowed cursor. While dragging the "drag" element, not-allowed cursor appears and I can't drag it anymore. How can i prevent that? I want to make my "drag" element always be "absolute" while mouse is down. Note: I know that it can happens becouse "pointer-events" but I need it to be contained into this code. Some code: $("#drag").bind({ mousedown : function (e) { var dragged = $(this); dragged.css({ left : e.pageX - (50 / 2), top : e.pageY - (50 / 2) }); dragged

Using David J Bradshaw's iframe-resizer

三世轮回 提交于 2021-02-07 17:38:13
问题 I have a Teamspeak status viewing script hosted on a different domain than my wordpress. So I'm trying to show the script results in a text/html widget using an iframe except it will not auto-size the height. Wordpress is on shared hosting so this script will not communicate with my teamspeak server from there. I cannot find any other ts3 viewers that work while auto-hide empty channels and not completely ugly. After doing some research I came across what appears to be the latest and greatest

Using David J Bradshaw's iframe-resizer

浪子不回头ぞ 提交于 2021-02-07 17:34:47
问题 I have a Teamspeak status viewing script hosted on a different domain than my wordpress. So I'm trying to show the script results in a text/html widget using an iframe except it will not auto-size the height. Wordpress is on shared hosting so this script will not communicate with my teamspeak server from there. I cannot find any other ts3 viewers that work while auto-hide empty channels and not completely ugly. After doing some research I came across what appears to be the latest and greatest

jQuery.parseJSON not working for JsonResult from MVC controller action

ぃ、小莉子 提交于 2021-02-07 17:22:13
问题 I am trying to use jQuery.parseJSON to parse out the return value from an MVC3 controller action. Controller: [HttpPost] public JsonResult LogOn(LogOnModel model, string returnUrl) { .. do stuff .. if (errors.Count() < 0) { return Json(new object[] { true, model, errors }); } return Json(new object[] { false, model, errors }); } jQuery: $.ajax({ url: form.attr('action'), type: "POST", dataType: "json", data: form.serialize(), success: function (data) { var test = jQuery.parseJSON(data); } });

Why wont IE fire on paste event?

筅森魡賤 提交于 2021-02-07 17:14:47
问题 I need help figuring out why Internet Explorer won't fire my 'paste' event. I'm using IE 11. Here is my code: $(document).on('paste', '.pasteTarget', handlePaste); When trying this in IE, the function never gets called. It works in chrome. 回答1: Different browsers treat onpaste differently, or not at all. For IE 11, the latter seems to be the case. From MDN: Non-Standard This feature is non-standard and is not on a standards track. Do not use it on production sites facing the Web: it will not

Why wont IE fire on paste event?

大城市里の小女人 提交于 2021-02-07 17:14:45
问题 I need help figuring out why Internet Explorer won't fire my 'paste' event. I'm using IE 11. Here is my code: $(document).on('paste', '.pasteTarget', handlePaste); When trying this in IE, the function never gets called. It works in chrome. 回答1: Different browsers treat onpaste differently, or not at all. For IE 11, the latter seems to be the case. From MDN: Non-Standard This feature is non-standard and is not on a standards track. Do not use it on production sites facing the Web: it will not