How to use jQuery to get the current value of a file input field
You need to use val rather than value. $(“#fileinput”).val();
You need to use val rather than value. $(“#fileinput”).val();
You can do this by using measureText var canvas = document.getElementById(“canvas”), ctx = canvas.getContext(“2d”) canvas.width = 400; canvas.height = 200; ctx.fillStyle = “#003300″; ctx.font=”20px sans-serif”; var textString = “Hello look at me!!!”, textWidth = ctx.measureText(textString ).width; ctx.fillText(textString , (canvas.width/2) – (textWidth / 2), 100); Live Demo More elaborate demo
You will not be able to store objects/arrays in the value attribute, however an option would be to use data-* attributes which supports json automatically with jQuery 1.4.3+ <select> <option data-value=”{“name”:”rajiv”,”age”:”40″}”>a</option> <option data-value=”{“name”:”mithun”,”age”:”22″}”>f</option> </select> And using .change() $(“select”).change(function(){ alert($(this).find(“:selected”).data(“value”).age); }); Example on jsfiddle
Select2 API v3.x (sortResults) You can sort elements using sortResults callback option with String.localeCompare(): $( ‘#mylist’ ).select2({ /* Sort data using localeCompare */ sortResults: data => data.sort((a, b) => a.text.localeCompare(b.text)), }); <link rel=”stylesheet” href=”https://cdnjs.cloudflare.com/ajax/libs/select2/3.5.4/select2.min.css” integrity=”sha256-ijlUKKj3hJCiiT2HWo1kqkI79NTEYpzOsw5Rs3k42dI=” crossorigin=”anonymous” /><script src=”https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js” integrity=”sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=” crossorigin=”anonymous”></script><script src=”https://cdnjs.cloudflare.com/ajax/libs/select2/3.5.4/select2.min.js” integrity=”sha256-7A2MDY2eGSSUvgfbuH1IdzYk8qkEd3uzwiXADqPDdtY=” crossorigin=”anonymous”></script> <select name=”list” id=”mylist” style=”width:140px;”> <option>United States</option> <option>Austria</option> <option>Alabama</option> <option>Jamaica</option> <option>Taiwan</option> <option>canada</option> <option>palau</option> … Read more
You can do this (fiddle here), make some sort of easy to use plugin: $.fn.getType = function(){ return this[0].tagName == “INPUT” ? this[0].type.toLowerCase() : this[0].tagName.toLowerCase(); } And use it like this $(“.element”).getType(); // Will return radio, text, checkbox, select, textarea, etc (also DIV, SPAN, all element types) $(“.elList”).getType(); // Gets the first element’s type Which … Read more
Answer from: http://forum.jquery.com/topic/sortables-update-callback-and-connectwith update: function(e,ui) { if (this === ui.item.parent()[0]) { //your code here } }
The problem is, that menuHoverStart is not accessible outside of its scope (which is defined by the .ready() callback function in file #1). You need to make this function available in the global scope (or through any object that is available in the global scope): function menuHoverStart(element, topshift, thumbchange) { // … } $(document).ready(function() { … Read more
I think you’re looking for something like this function colName(n) { var ordA = ‘a’.charCodeAt(0); var ordZ = ‘z’.charCodeAt(0); var len = ordZ – ordA + 1; var s = “”; while(n >= 0) { s = String.fromCharCode(n % len + ordA) + s; n = Math.floor(n / len) – 1; } return s; } … Read more
Try using this jquery plugin: Scrollorama. It has tons of cool features and you can use window.location.hash to update your browsers hash. Alternatively, you can add a “scroll” event to check when an anchor is reached. Here is a working fiddle to illustrate the event: http://jsfiddle.net/gugahoi/2ZjWP/8/ Example: $(function () { var currentHash = “#initial_hash” $(document).scroll(function … Read more
The first parameter should be sequence. Thus, this will not work: let blob = new Blob(data, { type: “application/pdf” }); But this will: let blob = new Blob([data], { type: “application/pdf” });