0

I would like to build a sort of all-purpose primitive CMS based on a kind of advanced editable area concept. The concept is the following:

A web site is built by dividing the content into a number of DIVs. Inside each DIV the developer places images, text, etc.

When the user enters the administration area, by hovering the mouse above the editable DIVs these are highlighted. If the user clicks one the DIVs a modal window pops up. This modal window contains a form with which the user may change the content of the DIV.

I know there are many 'editable area' scripts and I did used them, but this would be more generic as it would work with images too (upload/delete).

For example, let's say that a DIV contains some text. By clicking this DIV a modal window pops up with a form with one input field and a submit button that offers the user to change the text inside that DIV. If the clicked DIV has one image and some text the modal window should contain an input field to change the text, a upload field to upload a new image, a submit button and delete button to delete the image.

Click here to understand the layout (this is not a working example)

In conclusion I would like to know if there's a way with jQuery to get the type of elements

<input> <img> <textarea> etc

the name given to the elements and their ids inside the clicked DIV to dinamically build the modal window needed to edit the choosen DIV.

Thank you

Nicero
  • 4,181
  • 6
  • 30
  • 52
  • I found something interesting here: http://stackoverflow.com/questions/341900/how-can-i-determine-the-element-type-of-a-matched-element-in-jquery – Nicero Nov 28 '11 at 10:59

2 Answers2

1

Looks like you want jQuery's html()

http://api.jquery.com/html/

It will retrieve all the html contents of the element

For example:

$("div#main").click(function(){
   var allhtml = $(this).html();
   $("div#modalID").html(allhtml);

)};

This would take all the html in the div with ID main, save it to a variable allhtml and then replace everything in the div with ID modalID with it.

Gregg B
  • 13,139
  • 6
  • 34
  • 50
0

if you must use jquery

jQuery("???").get(0).tagName
thkala
  • 84,049
  • 23
  • 157
  • 201
Itay Kinnrot
  • 721
  • 5
  • 11
  • also i found this in this site: http://stackoverflow.com/questions/411688/how-to-extend-jquery-to-make-it-easier-to-retrieve-the-tagname – Itay Kinnrot Nov 24 '11 at 15:06