Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8399161
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T21:13:36+00:00 2026-06-09T21:13:36+00:00

The data-attribute stuff is new to me and just realized I need to escape

  • 0

The data-attribute stuff is new to me and just realized I need to escape space, comma, etc. Can anyone give me some suggestions on my approach? Below is my code:

#A list holds all the strings to be sent to data-attribute, 
#the sequence and length of the list is dynamic, determined by the user 
#(That's why I need to find a way to escape automatically.

Apt_p = []
Apt_p.append('Relative to planting')
Apt_p.append('Relative to harvest')
Apt_p_j=json.dumps(Apt_p) #convert everything into JSON for future usage

#I think below is the place to let escape happen.
html = """<td id="Apt_p_j" data-val=%s></td>""" %(Apt_p_j)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T21:13:38+00:00Added an answer on June 9, 2026 at 9:13 pm

    Put your attribute value inside double quotes so you don’t need to worry about escaping spaces. Then escape it just like you would escape any other attribute in quotes. Your web framework should have a function for that.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have assigned a custom data attribute to some circles added to the Raphael
I can use the jquery .data attribute and an alert confirms that it worked,
I am new to core data so please excuse me if I get some
So any custom data attribute that I use should start with data-: <li class=user
I am trying to retrieve a data attribute of type Boolean from an html
How do i select elements that have my custom data attribute data-validate with jQuery
The goal: Correctly put a string from a data attribute into the window.location.hash .
I have data-segment attribute in my body tag that is changed by a slider.
I am trying to add a custom data-required attribute to an asp Checkbox control,
So I am trying to sort an un-ordered list by the data-id attribute of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.