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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T03:41:02+00:00 2026-06-12T03:41:02+00:00

I have a button I’m using to toggle between displaying yes/no ‘in-policy’ divs <form>

  • 0

I have a button I’m using to toggle between displaying yes/no ‘in-policy’ divs

<form>
<input type="radio" id="Policy0" name="Policy" value="0" onclick="filterHotel();"><label for="Policy0">All</label>
</form>
<script type="application/javascript">
var Policy = $('input:radio[name=Policy]:checked').val()
if (Policy == 0) {  
 $('form [data-policy="0"]').toggle();              
}
</script>

<div id="24448" data-policy="0">Data here</div>
<div id="24448" data-policy="1">Data here</div>

With the code above I can successfully show/hide the correct div, but my issue is I don’t want to wrap my input in a form element. Is there a way to reference based on a value in an attribute?

I’ve tried $('input[attr=data-policy][value="0"]').toggle(); but that doesn’t seem to work. I’m sure I’m missing something simple, can someone point me in the right direction?

EDIT: $('input[data-policy="0"]').toggle(); does not work, i don’t get an error, but it doesn’t hide a div with an attribute of data=policy="0" I also tried data-policy=0 with no luck

  • 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-12T03:41:04+00:00Added an answer on June 12, 2026 at 3:41 am

    This should suffice:

    $('[data-policy="0"]').toggle(); 
    

    For further info, you can take a look at Attribute Equals Selector [name=”value”] documentation

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

Sidebar

Related Questions

I have button on my HTML page. Initially i was using <input name=op id=changepass_submit
I have button which post values of form to url but during post i
I have Button inside application.resources DataTemplate : <DataTemplate x:Key=contactItem DataType={x:Type Model:Contact}> <Button x:Name=openButton Style={StaticResource
I have button, which i rotated 45 degrees using rotate animation and applied on
i have one question regarding creation of divs: I have button, when user clicks
I have usercontrol in my page loaded using Page.Controls.Add(ctrl) Now, I have button in
I have button at first column in datagrid. I am using MVVM and try
i have button click handler event in which i am using if-else condition.How can
I have dropdown list using select_tag and I have button near it. I have
I am using a list view in which i have button for downloading. I

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.