Add file input dynamically to form using jQuery
Problem You have basic form with file input field and you want to add new fields dynamically. <form id="upload" action="upload.php" method="POST" enctype="multipart/form-data"> <label...
View ArticleFancybox doesn’t show div
Problem Showing div using fancybox doesn’t show nothing. Fancybox code $("#myDiv").fancybox(); Solution You can do a simple workaround. $.fancybox({ content: $("#myDiv").html() }); This will show...
View ArticleRead hash from URL as key-value pairs using javascript
Problem How to get key-value pairs from hash(location.hash) part of URL via javascript? Solution function parseHashArgs(aURL) { aURL = aURL || window.location.href; var vars = {}; var hashes =...
View ArticleHow to add parameters to URL with javascript
Problem How to add parameters to URL that may already contain some parameters and/or anchor using javascript? Solution I’ve found solution on stackoverflow. Here is the code function addParameter(url,...
View ArticlejQuery – use for loop to bind events
Problem Binding events in for loop with jQuery is not working. Here is example of not working code. for(var i = 0; i < 5; i++){ $("#selector"+i).click(function(){ $("#selector"+i).hide(); }); }...
View ArticleAlloyUI modal – set headerContent dynamically
Problem How to set the AlloyUI Modal headerContent attribute dynamically? Solution The solution is simple. You call the .set("headerContent", "My header content") method on the modal object. Example of...
View Article