1

I need to add a span element to a specific in Sharepoint List New Form.But, how to get that specific td element using jquery ot javascript. Anyone can help me in this?enter image description here

beside to single line text field i have to append span tag.how can i get that specific td.

3
  • You want to get the value of input text box (as a td element) ? Oct 15, 2018 at 12:17
  • Not to get the value of input text box .I want to get the <td> element of the above text box...
    – Swetha
    Oct 16, 2018 at 4:54
  • Please refer to my answer, hope it helps! Oct 24, 2018 at 16:36

3 Answers 3

1

To find the Span element, do the following.

  • Select New Form - copy the url and paste in to Google Chrome.

  • Press F12 - to open developer view. Then click on the symbol I've circled in red:

Dev View

The span in the above picture is of the options in a choice field.

In the picture below the span is of the field name:

span field name

2
  • i dont have <nobr> tag in my accordion UI. so am stuck at how to add this?
    – samolpp2
    Apr 5, 2019 at 8:07
  • 1
    The <nobr> is wrapped around the field name. If you have no <nobr> that would suggest to be that you have no fields present on your form...or, having done a quick search I found this explanation which should help :-) stackoverflow.com/questions/28532076/why-is-the-nobr-deprecated
    – Tally
    Apr 16, 2019 at 9:22
1

To get specific <td> tag in Sharepoint List New Form, Try this

$('h3:contains("Field Name")').closest('td').next('td')

Edit based on your comment

To append an HTML tag like span or div, do the following:

$('h3:contains("Field Name")').closest('td').next('td').append("<span>Test</span>");
2
  • within this td($('h3:contains("Field Name")').closest('td').next('td')) how to add span element?
    – Swetha
    Oct 16, 2018 at 7:11
  • if its an accordion UI, then the above wont work!! if i add this $('h3:contains("Field Name")').closest('td').next('td').append("<span>Test</span>"); , it will not show accordion ui at all!
    – samolpp2
    Apr 5, 2019 at 8:05
0

To append span element to td using jQuery:

var spanTag = "<span></span>";
$('h3:contains("Field Name")').closest('td').next('td').append(spanTag);

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.