How to append text/html aside other jquery tags in JQuery

تبليغ
سؤال

يرجى شرح بإيجاز لمإذا تشعر أنك ينبغي الإبلاغ عن هذا السؤال.

تبليغ
‎إلغاء

I am trying to design a calendar component and the html for the section is:

<th id=”thNow”>July<span class=”scrollArrow”><img src=”/UpDownArrow.png” /></span>, 2022<span class=”scrollArrow”><img src=”/UpDownArrow.png” /></span></th>

In JQuery (3 if it matters), the code I’m attempting with it is:

var thNow = $(“<th></th>”, { id: “thNow” })
.html(sMonth)
.append(
$(“<span></span>”, { “class”: “scrollArrow” })
.append(
$(“<img />”, { “src”: “/UpDownArrow.png” })))
.html(“, “)
.html(sYear)
.append(
$(“<span></span>”, { “class”: “scrollArrow” })
.append(
$(“<img />”, { “src”: “/UpDownArrow.png” })));

even though I know that won’t work – How do I effectively piece together the string of the Month name like with .html(), an img tag, the text “, ” and the year, and another image tag – This Jquery code just replaces the Month name with the year and the image tag.

Do I need to wrap each of the text in a span/div or something? Eventually (after I add the code that is), the month name and year will be links to select a month out of all the months and a year out of all the years like one might see in a date picker but this is more than just a date picker.

It’s for my own personal calendar to merge my work and home calendars to make a sort of calendly site for myself but which will use google apis to query my google calendar and Office APIs to query my work calendar and people (or I) can add events to it as well.

Is there a way to do what I want or do I need to definitely wrap each of the text things in a tag of some sort?

0
X 5 أشهر 2022-07-10T12:01:21+03:00 0 إجابة 0 مشاهدات مبتدئ 0

‫أضف إجابة

تصفح
تصفح

مجهول يجيب