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 7937311
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T22:29:43+00:00 2026-06-03T22:29:43+00:00

I can’t find anything in the documentation about val() and prop() and escaping. Are

  • 0

I can’t find anything in the documentation about val() and prop() and escaping.

Are they intended to escape values when used as setters?

  • 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-03T22:29:44+00:00Added an answer on June 3, 2026 at 10:29 pm

    Not really. .val() is used to set a form field’s value attribute, so escaping isn’t really necessary there. You’ll be setting the value via the DOM, so it’s not like you’re constructing HTML through string concatenation. .prop(), on the other hand, doesn’t even interact with attributes at all – just DOM properties, so you don’t need to working about HTML escaping their either.


    Edit: for the sake of clarification, I’m assuming that you’re asking this because you’re concerned about .prop() or .val() as an XSS attack vector (or just an opportunity to shoot yourself in the foot)? If that’s the case, you need to remember that when setting attributes and properties via the DOM, the values that you set are essentially sandboxed to the attribute or value you were interacting with. For example, given the following:

    <div id="foo"></div>
    

    And you attempted to abuse an attribute value, such as:

    $('#foo').attr('rel', '"></div><script>alert("bang");</script><div rel="');
    

    You might be concerned that this would result in something like the following:

    <div id="foo" rel=""></div><script>alert("bang");</script><div rel=""></div>
    

    This will never happen, though. You will indeed have a rel attribute with the evil-looking string as its value, but no new markup or DOM nodes will be created. The string itself isn’t escaped – it’s just simply not interpreted as markup. It’s just a string and that’s it.

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

Sidebar

Related Questions

Can I be sure about the order in a Python dictionary? The function op.GetTangent(id)
Can somebody point me to a resource that explains how to go about having
Can anyone (maybe an XSL-fan?) help me find any advantages with handling presentation of
Can not find scala.actors package in latest milestones, while it still presents in scaladocs:
Can find why i get this error can someone help? package Android.data; public class
Can anyone help me trying to find out why this doesn't work. The brushes
Can wildcards be used in the static pattern rule context in GNU make? For
Can somebody recommend some papers (literature) or code snippets about tree-based diff algorithms for
Can anyone let me know how can we change the value of kendo combobox
Can I order my users in the database, so I don't have to say

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.