1

I would like to add a custom id tag e.g. id = keys[key][each]as part of the html that's being appended to the new_resumes class e.g. I would like

<div class = "filtered_results" id = keys[key][each] ...

instead with the code below - when I use the attr or prop tag it adds an id to the new resumes class. I appreciate my code is not the greatest.

for (var key in keys) {
    $(".new_resumes").append("<div class='filtered_results' style='color:white; background-color:red; text-align:center; height:20px; line-height: 20px'>" + key + "</div>");
    for (var each in keys[key]) {
        $(".new_resumes").append("<div class='filtered_results' style ='height:60px; text-align:center; height:60px; line-height: 60px;'>" + keys[key][each][0] + "</div>").prop('id',keys[key][each][0]);

1 Answer 1

2

If I understand your question, you want to add the ID to the filtered_results div you are creating?

You should just concatenate it like so:

$(".new_resumes").append("<div class='filtered_results' id='" +keys[key][each][0] +"' style ='height:60px; text-align:center; height:60px; line-height: 60px;'>" + keys[key][each][0] + "</div>")

Take note of this part: id='" +keys[key][each][0] +"'

Right now, you are calling .prop on the current element which is still the .new_resumes element.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.