Cannot get the HTML value of a dd element with jQuery

Please help, I cannot get the html value of a dd element.

This is my code:

<table id="tabla_costo"> <h2> Costo de Producción </h2> <dl> <dt>Codigo></dt> <dd class="code"> &nbsp; </dd> <dt>Codigo Secundario></dt> <dd class="code2"> &nbsp; </dd> <dt>Producto</dt> <dd class="name"> &nbsp; </dd> <dt>Cantidad</dt> <dd class="quantity"> &nbsp; </dd> <dt>Costo</dt> <dd class="cost"> &nbsp; </dd> </dl> </table>

I've tried this, but does not work:

var dl = $('#tabla_costo dl').find('dd.code').first().html(); console.log(dl);

But I'm getting undefined

This is my jsfiddle: (updated)

-------------Problems Reply------------

This is because your <table> has no rows or cells, so it's not a valid DOM structure.

If you change your <table> so that its content is in a cell:

<table id="tabla_costo">

it all works fine.

Following the answer from @RichieHindle, the only solution that would work here is the following.

var dl = $('dl').find(".code").html();

Category:javascript Views:73 Time:2019-03-15

Related post

  • Get the HTML that makes up an element in Jquery or Javascript? 2010-09-01

    How do I get the HTML that makes up an element using Jquery or Javascript? For example if I have an element that looks like <div id="theDivIWant" class="aClassName" style="somestyle: "here"></div> I can grab a reference to it using var x

  • Get the type of a given XML element with jQuery? 2011-06-23

    How can I figure out the type of a given XML element with jQuery? For example, if I want the type of the second child: XML: <xml> <a>a element</a> <b>b element</b> <c>c element</c> </xml> JS: var node =

  • How to get the html source of a specific element with selenium? 2009-11-29

    The page I'm looking at contains : <div id='1'> <p> text 1 <h1> text 2 </h1> text 3 <p> text 4 </p> </p> </div> I want to get all the text in the div, except for the text that is in the <h>. (I wa

  • How does one get the width of an absolute/fixed element with jquery/js, on resize? 2011-04-11

    Lets say you have a fixed or absolute positioned element: <div> My fixed div. </div> With the following css: div:first-of-type { background-color: red; position: fixed; top: 20px; left: 20px; right: 20px; bottom: 20px; } You can figure ou

  • Get the HTML value which is not in a tag in c# 2010-10-24

    I have an HTML string that has the following form: <tr valign="top"><td colspan="2" style="padding-bottom:5px;text-align: left"><label for="base_1001013" style="margin-bottom: 3px; float: left">Nom d'utilisateur:&nbsp;</label

  • How to get the keypress value from an event object in jQuery 2009-05-17

    I want to disable users from entering a character into a HTML text input field that isnt a letter or number. This exact functionality can be seen on the Twitter signup page (username field) Im trying to write this in jQuer

  • How do get the different values that takes an attribute with a django query? 2010-02-22

    I have this Model in django : class Post(models.Model): title = models.CharField(max_length=255) category = models.CharField(max_length=255) I would like to get the different values that are used in the category attribute. For example, if we consider

  • How to get the rotation value of a UI Element in WPF 2010-04-05

    I've figured out how to assign a rotation value (element.RenderTransform = new RotateTransform(x)), but how do I get the rotation value of the element? For example, if I wanted to make one ui element have the same rotation angle as another ui element

  • Get the html that makes up an element reference? 2010-09-09

    Does anybody know, if i have an object like $('#input') how can I get the html that would make it up, like <input id="input" /> as a text string? Thanks! --------------Solutions------------- Any of the outerHTML plugins, like this will work: jQ

  • Getting the parameters values as null while working with custom wsdl file in axis2 2011-08-10

    I have a web service method which takes a parameter. If I am not using any custom wsdl file, then it is working very fine. But it doesn't work when I use my custom wsdl file generated using axis2 code generation wizard in eclipse. I get the parameter

  • How to get currently selected value of a multiple select with Jquery 2012-02-02

    I have a multiple select dropdown box. I need to make an ajax call every time an item is selected, but am having a problem getting the specific value from the select menu. Instead of retrieving the currently selected value, I get an array of all sele

  • How to get all option values in a multiple select with jquery? 2012-02-22

    I'm trying to get all options values of a multiple select with the following code. var service_m = $("#SelectRight>option").map(function () { return $(this).val(); }); When I do this I only get [object Object] in return. Any suggestions on how to

  • C# Registry.GetValue cannot get the correct value 2011-03-03

    In my code, I need to get the time zone of Venezuela from Registry. What I want is the Index value under the key "Venezuela Standard Time". I use the following code to do that, but seems it do not work correctly. The number returned is "-2147483573",

  • Why I cannot get the return value of require_once function in PHP? 2014-10-08

    I already know that include_once would return true or false based on including that file. I've read a question on Stackoverflow about using require_once to return your value and print it out. The problem is that I have an existing project in hand, an

  • Cannot get the return values of stored procedure mysql 2012-04-08

    I want to get the out parameter of stored procedure using Zend framework Here's the procedure DELIMITER // CREATE procedure getAllUsers( out sysUsers VarChar(50) ) BEGIN DECLARE usersCursor CURSOR FOR SELECT username FROM SYSTEM_USERS; OPEN usersCurs

  • Get the current value of env.hosts list with Python Fabric Library 2010-07-26

    I've got this code (foo and bar are local servers): env.hosts = ['foo', 'bar'] def mytask(): print(env.hosts[0]) Which, of course prints foo every iteration. As you probably know, Fabric iterates through the env.hosts list and executes mytask() on ea

  • Cannot get the counters to move (game in C# with PictureBox). 2009-12-13

    I'm trying to learn C# (so go easy on me!) and as part of a coursework I have been asked to create a game called strikeout. The game rules are very simple. It is simply a case of knocking one counter into another, with the aim of leaving one counter

  • How get the :hover css style of an anchor with jQuery? 2009-03-17

    How can i get the :hover in css stylesheet on the fly with jquery? stupid example: { color: red; font-size: 11px; } { color: blue; font-size: 12px; } how to retrieve that color and font-size before that mouse will go over the anchor

  • How do I get the width of a scaled SVG element with JavaScript? 2012-02-08

    If I have inline SVG, including an element which has been scaled... <g transform="scale(sX,sY)"> <rect id="myElement" x="107" y="32" width="245" height="31" stroke="#C6C3C6" stroke-width="1px" /> </g> ... or which is in a <svg

  • Set the actual value attribute of an input with jQuery 2009-10-28

    I am trying to reset the actual value attribute of an input so that it can be reset back to that value if reset, not necessarily the original value when the form was loaded. The problem is these changes don't seem to take effect. I have tried both: $

  • Can you set the defaultSelected value of a select element with javascript 2011-11-16

    Can you set the defaultSelected value of a select field programmaticlly with javascript. My problem is that when checking for values changed by the user I am getting true for the if condition below, when our developers programmaticlly change the sele

  • Get the width in pixels of an element using jquery 2010-11-18

    I want to get the width of an element including border, margin and padding. I know using $(input).width() or $(input).css('width') give the width of the element. But here is the requirement. Suppose I created a text box like follows: <input type='

  • How to get the text of an svg desc element with javascript 2011-02-20

    right now I have a group of svg elements (circle, rect, path, etc.).The actual document looks something like this. <desc>Some Text</desc> <rect id='a0' fill='green' ...> So when you you strip the a from the id you would get the corr

  • Not getting the visible tr's in a div with jquery 1.7.1 2012-02-29

    I have to get all visible trs and do some operation on all its td's. So I was using $('#divId tr:visible td') to get the result. This was working fine till i was using jquery 1.4.2 but when i replaced it with 1.7.1, it stopped working. http://jsfiddl

  • Get the higher result(s) from a questionnaire with jQuery 2012-03-22

    I'm trying to build a questionnaire / personality test with jQuery. I have an object in the end : results = { quality1 : 2, quality2 : 3, quality3 : 0, quality4 : 3, etc } I then want to retrieve the key with the higher value. No problem if there is

Copyright (C), All Rights Reserved.

processed in 0.237 (s). 11 q(s)