Quantcast
Channel: Active questions tagged html - Stack Overflow
Viewing all articles
Browse latest Browse all 72388

How to insert a dynamic object

$
0
0

Here is the JS in question (with google.com as just an example):

 let postNumber = $("div[id^='product-']").attr("id");
const productId = "product-",
            AWS = "https://google.com/bar-images/SPECSHEET_PDF/";

let foo = {

    "28162":  AWS + "R3CRDT_DIMTOWARM_SPSHT.pdf",
    "28163":  AWS + "R3CRPT_DIMTOWARM_SPSHT.pdf",
    "28164":  AWS + "R3CRWT_DIMTOWARM_SPSHT.pdf",
    "28165":  AWS + "R3CRDL_DIMTOWARM_SPSHT.pdf",
    "28166":  AWS + "R3CRPL_DIMTOWARM_SPSHT.pdf",
    "28167":  AWS + "R3CRWL_DIMTOWARM_SPSHT.pdf",
    "28168":  AWS + "R3CRDT_DIMTOWARM_SPSHT.pdf",
    "28169":  AWS + "R3CRDT_DIMTOWARM_SPSHT.pdf",
    "28170":  AWS + "R3CRDT_DIMTOWARM_SPSHT.pdf",
    "28171":  AWS + "R3CRDT_DIMTOWARM_SPSHT.pdf",
    "28172":  AWS + "R3CRDT_DIMTOWARM_SPSHT.pdf",
    "28173":  AWS + "R3CRDT_DIMTOWARM_SPSHT.pdf"

  };

  $("div[id='product-" + postNumber + "] ul#dropdown-download-links > li > ul > li:last-of-type").href(foo[]);

Keep in mind AWS is just the static URL for the files.

How would I get a dynamic version of the .href() link value using bracket notation with the object foo. As you can see I have the jQuery statement to retrieve the URL from the above object. I just can't figure out the last part where I would enter .href(foo[something]); dynamically? Any ideas? Or maybe a better way og doingi t?


Viewing all articles
Browse latest Browse all 72388

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>