I would like to retrieve the Selected value from a SharePoint List Filter to use in a url. I have the following code in a CEWP on the same page as the SP List Filter that returns an alert box to test the result for now. This script is returning all data within the web part instead of only the selected value.

$(document).ready(function() {
    var filterValue = $("#WebPartWPQ5").text();
    if (filterValue != null) {
    alert("filter value is: "+ filterValue);

Thanks in advance,



You get the whole text because


Give me all readable text inside all HTML elements, from the DOM element with id=WebPartWPQ5

So you need to check the F12 Dev Elements window (right click: inspect element) for your filter DOM element,
and use the proper selector.


  • Thank you for your response. My issue is in finding the correct DOM element for the List Filter Web Part. I believe I could select the proper selector once I have the right element. I guess "WebPartWPQ5" is not correct. – Jason David Nov 27 '16 at 2:40

Here is what worked. Credit to How to get value of List Filter web part in Javascript?

SP.SOD.executeFunc('sp.js', 'SP.ClientContext', selectedVal);
function selectedVal() {
   var filter = $("input[id$='SpListPicker_Selection']");

I was also able to use the script below to retrieve the parameter value from a selected form library row. This ultimately allowed me to pass the selected parameter to a new page. Example url after selecting the form library item: ...SitePages/Home.aspx?View=%7B98A6C39A%2DEB04%2D4F92%2DB55A%2D6465EF81678E%7D&SelectedID=6

function selVal()
   var q = JSRequest.QueryString["SelectedID"];
   alert("Selected ID = "+q);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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