Skip to content

Tag: html

Getting HTML form values

How can I get the value of an HTML form to pass to JavaScript? Is this correct? My script takes two arguments one from textbox, one from the dropdown box. Answer HTML: JS:

How to scale an imageData in HTML canvas?

I have a canvas in my webpage; I create a new Image data in this canvas then I modify some pixel through myImgData.data[] array. Now I would like to scale this image and make it bigger. I tried by scaling the context but the image remains small. Is it possible to do this? Thanks Answer You could draw the imag…

jQuery: how to change tag name?

jQuery: how to change tag name? For example: I need Yes, I can Create DOM element <div> Copy tr content to div Remove tr from dom But can I make it directly? PS: results in DOMException. Answer You can replace any HTML markup by using jQuery’s .replaceWith() method. example: http://jsfiddle.net/JH…

Adding HTML elements with JavaScript

So, if I have HTML like this: How can I use JavaScript to add an HTML element where that blank line is? Answer As you didn’t mention any use of javascript libraries (like jquery, dojo), here’s something Pure javascript. or

I am trying to make a simple toggle button in javascript

I am trying to make a simple toggle button in javascript. However, the button will only turn “OFF” and will not turn back “ON” I am running:HP Netbook : Ubuntu Linux 10.04 : Firefox for Ubuntu 1.0. Answer Both of your if statements are getting executed one after each other, as you chan…

How to get caller element using JavaScript?

I have a table with id “tbl” and it has 2 rows and 3 cols. Each cell (td) has an explicitly defined id. Also, the table has an onclick event that calls a function foo(). The onclick() would be generated whenever any cell is clicked. The table tag is: I also tried javascript:foo(this) I want to fin…