This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Create a Table as a jQuery plugin

 
samuel marin
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 65115
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
samuel marin
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 65115
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 65115
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is the jsfiddle of what I'm trying


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

Thanks
 
samuel marin
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Solved.

Thanks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic