Jquery 如果url中有值,如何选中所有复选框?

Jquery 如果url中有值,如何选中所有复选框?,jquery,Jquery,我有这个网址: http://test.dev/search?publishing_types%5B%5D=Selling&prop_category%5B%5D=Apartment+%26+housing&priceFrom=0&priceTo=300000&areaFrom=0&areaTo=300000&yearFrom=1900&yearTo=2017 在功能中,我检查完整的url,如果url中存在该值,我想添加该值的复选框。有

我有这个网址:

http://test.dev/search?publishing_types%5B%5D=Selling&prop_category%5B%5D=Apartment+%26+housing&priceFrom=0&priceTo=300000&areaFrom=0&areaTo=300000&yearFrom=1900&yearTo=2017 
在功能中,我检查完整的url,如果url中存在该值,我想添加该值的复选框。有什么建议吗

  function existingUrl(fullUrl){
          $('.dataurl').each(function(){
            var hasValue =  fullUrl.indexOf($(this).val());
            if(hasValue != -1)
              this.checked = true;

        });
      }
HTML:

@foreach($prop\u类型为$index=>$prop\u类型)

{{$prop_type}

@endforeach
要获得干净的文本,您需要解码URI并替换任何剩余的编码。假设您有一个字符串变量,您可以按如下方式执行此操作

有关详细解释,请参阅

var str='公寓+%26+住房';

log('value='+decodeURIComponent(str.replace(/\+/g,'%20'))添加一些html会很有帮助。我更新了我的问题,它们都是sameit的已经工作!问题是什么?问题是当值来自两个或两个以上的单词时,我得到的像这个公寓+%26+住房,但我没有得到正确的值。请删除水平滚动条。谢谢。
  @foreach($prop_types as $index => $prop_type)
     <p class="customCheckBox no-padding-left">
        <input type="checkbox" class="preventUncheck dataurl" name="publishing_types[]" id="toggle-on{{ $index }}" value="{{ $prop_type }}" >

        <label for="toggle-on{{ $index }}" class="checkboxTitle">{{ $prop_type }}</label>
     </p>
   @endforeach