Search Results

Search found 4827 results on 194 pages for 'alert'.

Page 100/194 | < Previous Page | 96 97 98 99 100 101 102 103 104 105 106 107  | Next Page >

  • Using jQuery to gather all text nodes from a wrapped set, separated by spaces

    - by Bungle
    I'm looking for a way to gather all of the text in a jQuery wrapped set, but I need to create spaces between sibling nodes that have no text nodes between them. For example, consider this HTML: <div> <ul> <li>List item #1.</li><li>List item #2.</li><li>List item #3.</li> </ul> </div> If I simply use jQuery's text() method to gather the text content of the <div>, like such: var $div = $('div'), text = $div.text().trim(); alert(text); that produces the following text: List item #1.List item #2.List item #3. because there is no whitespace between each <li> element. What I'm actually looking for is this (note the single space between each sentence): List item #1. List item #3. List item #3. This suggest to me that I need to traverse the DOM nodes in the wrapped set, appending the text for each to a string, followed by a space. I tried the following code: var $div = $('div'), text = ''; $div.find('*').each(function() { text += $(this).text().trim() + ' '; }); alert(text); but this produced the following text: This is list item #1.This is list item #2.This is list item #3. This is list item #1. This is list item #2. This is list item #3. I assume this is because I'm iterating through every descendant of <div> and appending the text, so I'm getting the text nodes within both <ul> and each of its <li> children, leading to duplicated text. I think I could probably find/write a plain JavaScript function to recursively walk the DOM of the wrapped set, gathering and appending text nodes - but is there a simpler way to do this using jQuery? Cross-browser consistency is very important. Thanks for any help!

    Read the article

  • jquery function call with parameters

    - by Kaushik Gopal
    Hi a newb question: I have a table with a bunch of buttons like so: <tr class="hr-table-cell" > <td>REcord 1</td> <td> <INPUT type="button" value="Approve" onclick="" /> <INPUT type="button" value="Reject" onclick="" /> <INPUT type="button" value="Delete" onclick="fnDeletePpAppl(222445,704);" /> </td> </tr> <tr class="hr-table-cell" > <td>REcord 1</td> <td align="center" class="hr-table-bottom-blue-border" valign="middle"> <INPUT type="button" value="Approve" onclick="" /> <INPUT type="button" value="Reject" onclick="" /> <INPUT type="button" value="Delete" onclick="fnDeletePpAppl(237760,776);" /> </td> </tr> I have my jquery like so: <script type="text/javascript"> // JQUERY stuff $(document).ready(function(){ function fnDeletePpAppl(empno, applno) { alert('Entering here'); $("form").get(0).empno.value = empno; $("form").get(0).applNo.value = applno; $("form").get(0).listPageAction.value = "delete"; $("form").get(0).action.value = "pprelreqlist.do"; $("form").get(0).submit(); } }); This doesn't seem to work.I thought this means, the function is ready only after the dom is ready. After the dom is ready and i click the button, why is not recognizing the function declaration within the .ready() function? However if i use the function directly: <script type="text/javascript"> function fnDeletePpAppl(empno, applno) { alert('Entering here'); $("form").get(0).empno.value = empno; $("form").get(0).applNo.value = applno; $("form").get(0).listPageAction.value = "delete"; $("form").get(0).action.value = "pprelreqlist.do"; $("form").get(0).submit(); } This works. I want to get my fundamentals straight here... If i do the declaration without the .ready() , does that mean i'm using plain vanilla jscript? If i were to do this with the document.ready - the usual jquery declaration way, what would i have to change to make it work? I understand there are much better ways to do this like binding with buttons etc, but I want to know why this particular way doesn't seem to be working. Thanks. Cheers. K

    Read the article

  • Get ID of clicked on element in function

    - by skerit
    I want to get the ID of an element I click on. I put the function in the onclick element, like this: <a id="myid" class="first active" onclick="markActiveLink();" href="#home">Home</a> And this is in the function: function markActiveLink() { alert($(this).attr("id")); } This doesn't work, as it says it isn't defined. Does it really forget about the ID, do I have to type it in the onclick?

    Read the article

  • jquery not working in internet explorer using mvc

    - by Barry
    i have a group of radio buttons that are generated on the fly from the db into a partial control then rendered on the page as html and they all have the same name now in firefox and chrome the following code works fine $(".FlightSelectedRadio").live('click', function() { alert("after flight select"); $("#ToisGarantueedBid").attr("disabled", false); }); however in ie it doesnt work on the first select of a radio but only fires if u select something else ? any ideas wat the problem is ?

    Read the article

  • Correlation formula explanation needed d3.js

    - by divakar
    function getCorrelation(xArray, yArray) { alert(xArray); alert(yArray); function sum(m, v) {return m + v;} function sumSquares(m, v) {return m + v * v;} function filterNaN(m, v, i) {isNaN(v) ? null : m.push(i); return m;} // clean the data (because we know that some values are missing) var xNaN = _.reduce(xArray, filterNaN , []); var yNaN = _.reduce(yArray, filterNaN , []); var include = _.intersection(xNaN, yNaN); var fX = _.map(include, function(d) {return xArray[d];}); var fY = _.map(include, function(d) {return yArray[d];}); var sumX = _.reduce(fX, sum, 0); var sumY = _.reduce(fY, sum, 0); var sumX2 = _.reduce(fX, sumSquares, 0); var sumY2 = _.reduce(fY, sumSquares, 0); var sumXY = _.reduce(fX, function(m, v, i) {return m + v * fY[i];}, 0); var n = fX.length; var ntor = ( ( sumXY ) - ( sumX * sumY / n) ); var dtorX = sumX2 - ( sumX * sumX / n); var dtorY = sumY2 - ( sumY * sumY / n); var r = ntor / (Math.sqrt( dtorX * dtorY )); // Pearson ( http://www.stat.wmich.edu/s216/book/node122.html ) var m = ntor / dtorX; // y = mx + b var b = ( sumY - m * sumX ) / n; // console.log(r, m, b); return {r: r, m: m, b: b}; } I have finding correlation between the points i plot using this function which is not written by me. my xarray=[120,110,130,132,120,118,134,105,120,0,0,0,0,137,125,120,127,120,160,120,148] yarray=[80,70,70,80,70,62,69,70,70,62,90,42,80,72,0,0,0,0,78,82,68,60,58,82,60,76,86,82,70] I can t able to understand the function perfectly. Can anybody explain it with the data i pasted here. I also wanted to remove the zeros getting calculated from this function.

    Read the article

  • how to detect javascript features on Android 1.5

    - by Sirber
    I'm trying to write a code that can run on Android 1.5 and 2.0.1, but I have issues with the javascript engine used on Android 1.5. alert(localStorage); just hang on v1.5 while on v2.0.1 it alerts correctly. is there an unblocking way to do it or to detect the version of Android with javascript?

    Read the article

  • Javascript: how to access anonymous object within object?

    - by Caballero
    I have a string generated by php's json_encode() that looks like this: [ { "key1":"value1", "key2":"value2", "key3":"value3" }, { "key1":"value1", "key2":"value2", "key3":"value3" } ] I use Javascript function to convert the string to Javascript object: var jsonObj=JSON.parse(string); How do I access the data inside since the inner objects have no names? I tried something like: alert(jsonObj.firstChild.key1); It gives me "undefined". Why is that so?

    Read the article

  • Keyboard problem on iPhone OS 4.0 (8A248c)

    - by Newbee
    Hi! I have view with text field -- subclassed from UIAlertView. In the textFieldShouldReturn delegate I call resignFirstResponder for text field and dismissWithClickedButtonIndex for view. On the 3.x version everything fine, but on 4.0 keyboard still present on screen after view dismissing and doesn't disappear while app running. App compiled for 3.0 target and tested on 4.0 iPhone OS. One more thing - sometimes after dismissing alert - Done button on the keyboard replaces with Return button.. Any suggestions ?

    Read the article

  • Accessing ArrayList in Javascript - ASP.Net MVC2

    - by Shrikant
    Hi I have ArrayList in my Model and want to iterate through it in my javascript. I am using following code but its giving me error : CS0103: The name 'i' does not exist in the current context for(var i=0; i <= <%=Model.KeyList.Count%>; i++) { alert('<%=Model.KeyList[i]%>'); } How to get rid of this. its urgent...Please.

    Read the article

  • How to access child element out of children()?

    - by user291701
    Hi, I'd like to get the # of immediate children an element has, and then get the class of a child at a particular index. Something like: var index = 25; var children = $("#myListElement").children(); if (index < children.length) { if (children[index].hasClass("testClass")) { alert("hi!"); } } I think the syntax for .children() is ok, but how do I get the indexed element out of them in jquery style? Thanks

    Read the article

  • JQuery and radio buttons

    - by ognjenb
    <form id="Numbers1" <table id="numbers"> <tr> <th> prvi_br </th> <th> drugi_br </th> <th> treci_br </th> </tr> <% int rb = 1; %> <% foreach (var item in Model) { %> <tr> <td> <%= Html.Encode(item.prvi_br) %> <input type="radio" name="<%= Html.Encode(rb) %>" value="<%= Html.Encode(rb) %>" id='<%= Html.Encode(item.prvi_br) %>'/> </td> <td> <%= Html.Encode(item.drugi_br) %> <input type="radio" name="<%= Html.Encode(rb) %>" value="<%= Html.Encode(rb) %>" id='<%= Html.Encode(item.drugi_br) %>'/> </td> <td> <%= Html.Encode(item.treci_br) %> <input type="radio" name="<%= Html.Encode(rb) %>" value="<%= Html.Encode(rb) %>" id='<%= Html.Encode(item.treci_br) %>'/> </td> <% rb=rb+1; %> </tr> <% } %> </table> <p> <input type="submit" value="Save" /> </p> </form> With this script I get some info of selected radio: <script type="text/javascript"> $(document).ready(function() { var thevalue1; var thevalue2; $("#Numbers1").submit(function() { $("input:radio:checked").each(function() { thevalue1 = $("input:radio:checked").attr('id'); thevalue2 = $("input:radio:checked").val(); alert(thevalue1 + thevalue2); }); }); }); </script> If I have more rows this alert every time prints the information of first selected radio, why???

    Read the article

  • Set an event for a div with multiple class

    - by acidzombie24
    I am trying to set an event on a div whos parent has a class="classA classB"; My css is being applied but i cant figure out how to specify it with jquery. How do i set an event with jquery for this class combination $('[class=classA classB]').live('click', function () { alert('a'); }); html <div class="classA classB">...moredivs...</div>

    Read the article

  • Why can't I call this function (javascript/jquery)

    - by Ankur
    This is driving me nuts .... I have written a function function seraliseQuery(){ for(var i=1; i<=variables;i++){ alert(queryPreds[i]+" - "+queryObjs[i]); } } I just want to be able to call it from my other function $(".object").click( function() { // code removed seraliseQuery(); }); The error I get is "the function serialiseQuery() is undefined". Everything is within $(document).ready( function() { // code goes here }

    Read the article

  • What is wrong with this code? [closed]

    - by rajesh
    function checkLength(obj,url){ //alert("URL="+url+" OBJ="+obj); if(obj) { var params = 'query='+obj; var myAjax = new Ajax.Request(url, { method: 'post', parameters: params, onComplete: loadResponse }); } } The code isn't working, but I don't know why. I think I need to include other files, but I don't know which

    Read the article

  • JQuery Datepicker Date highlight Issue

    - by Isola Olufemi
    I have an in-line date picker in which I want to highlight some dates based on array of strings from the server side. I found out the on load of the page with the datepicker, events the matches in the current month will not be highlighted. when I click the next month button the events on the next moth will be highlighted. What I discovered that i the matching only get highlighted when I click to the next month and not when I click back to the previous month. Below is my script: var actionCalDates = new Array(); function getDates(month, year) { $.ajax({ url: "/Index/GetAllAlerts", data: { month: month, year: year }, success: function (result) { var date = new Date(); var i = new Number(date.getMonth()); i += 1; actionCalDates = result.split(","); } }); } function getTitle(ar, d) { var result = ""; for (var i = 0; i < ar.length; i++) { if (ar[i].indexOf(d) != -1) { var e = actionCalDates[i].split(";"); result += e[0] + "\n"; } } return result; } $('#calendar').datepicker({ numberOfMonths: [1, 1], showCurrentAtPos: 0, dateFormat: 'dd/mm/y', beforeShowDay: function (thedate) { var theday = thedate.getDate(); var x = new Number(thedate.getMonth()); x += 1; var date = thedate.getDate() + "/" + x + "/" + thedate.getFullYear(); getDates(x, thedate.getFullYear()); for (var i = 0; i < actionCalDates.length; i++) { var entry = actionCalDates[i].split(";"); if (date == entry[1]) { return [true, "highlight", getTitle(actionCalDates, date)]; } } return [true, "", ""]; }, onChangeMonthYear: function (year, month, inst) { getDates(month, year); }, onSelect: function (d, instance) { $.ajax({ url: '/Index/AlertConvertDate', datatype: 'text', data: { dateString: d }, error: function (xhr, ajaxOptions, thrownError) { alert(xhr.statusText); alert(thrownError); }, success: function (data) { window.SetHomeContent(data); } }); } }); Please can someone point out where I went wrong? Thank you all.

    Read the article

  • Jquery Dom and functions in html body

    - by slick
    I have before my closing body tag here i have the usual $(function() { function test(){ alert("test"); } }); in my html i have input tags I get an error of that test is undefined. I am trying to make IE7 call function onchange I had a whole solution working but since IE7 does not like .change() i am going to put onchange attributes within the inputs but now i have this issue. Any idea how I can solve this?

    Read the article

  • Jquery forms plugin problem

    - by Dudul
    I have the following: $(document).ready(function(){ // bind 'myForm' and provide a simple callback function $('#form').ajaxForm(function() { alert("Works!!!"); }); }); The problem is that when I dynamically add the form to the HTML the script is not working. If the form is there from the beginning the form is submitted with Ajax and works as expected. What is the problem here?

    Read the article

< Previous Page | 96 97 98 99 100 101 102 103 104 105 106 107  | Next Page >