How to open a file / browse dialog using javascript?

Here is a non-jQuery solution. Note you can’t just use .click() as some browsers do not support it. <script type=”text/javascript”> function performClick(elemId) { var elem = document.getElementById(elemId); if(elem && document.createEvent) { var evt = document.createEvent(“MouseEvents”); evt.initEvent(“click”, true, false); elem.dispatchEvent(evt); } } </script> <a href=”#” onclick=”performClick(‘theFile’);”>Open file dialog</a> <input type=”file” id=”theFile” />

Select first TD in every row w/ jQuery

Use the :first-child pseudo class instead of :first. $(“#myTable tr td:first-child”).addClass(“black”); The :first pseudo class actually selects the first element that was returned in your list. For example, $(‘div span:first’) would return only the very first span under the first div that happened to be returned. The :first-child pseudo class selects the first element under …

Read more

iphone/ipad triggering unexpected resize events

Store the window width and check that it has actually changed before proceeding with your $(window).resize function: jQuery(document).ready(function($) { // Store the window width var windowWidth = $(window).width(); // Resize Event $(window).resize(function(){ // Check window width has actually changed and it’s not just iOS triggering a resize event on scroll if ($(window).width() != windowWidth) { …

Read more

Is there a jQuery-like CSS/HTML selector that can be used in C#?

Update 10/18/2012 CsQuery is now in release 1.3. The latest release incorporates a C# port of the HTML5 parser. As a result CsQuery will now produce a DOM that uses the HTML5 spec for invalid markup handling and is completely standards compliant. Original Answer Old question but new answer. I’ve recently released version 1.1 …

Read more