*
The moose likes HTML, CSS and JavaScript and the fly likes Create a Table as a jQuery plugin Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Create a Table as a jQuery plugin" Watch "Create a Table as a jQuery plugin" New topic
Author

Create a Table as a jQuery plugin

samuel marin
Greenhorn

Joined: Nov 18, 2011
Posts: 16
I would like to know how can I create a HTML table in JQueryP code dinamicaly.

I would like to create a simple table like:

<table bgcolor=white width="245">
<tr>
<td>
<font color=darkblue size=3>Category 1</font>
<br>
<font color=#1dc4ff size=2><a href="">Element 1</a></font>
<br>
<font color=#1dc4ff size=2><a href="">Element 2</a></font>
</td>
</tr>
</table>



In something that I can code in my .jsp file. Something like:


(function( $ ) {


$.fn.MyTable = function(options) {

});
};


Thank you so much
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60780
    
  65

JSP or jQuery? You ask about JSP and then show code that creates a jQuery plugin.

Also, attributes such as bgcolor and tags such as <font> are deprecated and should not be used.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
samuel marin
Greenhorn

Joined: Nov 18, 2011
Posts: 16
Sorry, I was refering to JQuery.

Thanks

I'm trying to be able to create a Table dynamically since I'm going to have it in many different sites I don't want to change the table in all the sites each time I need to modify the table.

I tried the following and I don't know why is not working:


Calling it:

Thanks again
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60780
    
  65

Please read ItDoesntWorkIsUseless and tell us in detail what's not working.

Also, have you launched the JavaScript debugger and tried stepping through the code to see where it's going awry?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60780
    
  65

What is the purpose of calling the plugin on "#sidebar-lef" if you've hard-coded the table parent as "#output"?

Also, the table element is not self-closing, specify one of $('<table>') or $('<table></table>').
samuel marin
Greenhorn

Joined: Nov 18, 2011
Posts: 16
Here is the jsfiddle of what I'm trying


http://jsfiddle.net/samuvk/fbvXn/

Thanks
samuel marin
Greenhorn

Joined: Nov 18, 2011
Posts: 16
Solved.

Thanks
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Create a Table as a jQuery plugin
 
Similar Threads
Take the quiz: Which sci-fi crew would you fit best in?
Automatic flushing of response
Struts1 to Struts2 Migration
INCLUDES.DBconnection error
SqlException accured at processing Jsp